Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Need to include the machine that fail RPC connection

$
0
0

The below code gives me free drive space.  I have had a request to add the failed machines to the same list and specify in the report that the machine failed. When running the script manually it will show the failed machines on the window, however, we will be running this automatically and it would be nice if the failed machine(s) would still show up in the list.  If anything, they can just have no data which will be easy to see.  Any idea on how to do this? 

$servers = get-content servers.txt
foreach ($server in $servers)
{
Get-WmiObject Win32_LogicalDisk -filter 'DriveType=3' -computerName $server |
 Select-Object `
  SystemName,
  DeviceID,
  VolumeName,
  @{N='Size(GB)';E={ '{0:N2}' -f ($_.Size/1GB)}},
  @{N='FreeSpace(GB)';E={ '{0:N2}' -f ($_.FreeSpace/1GB) }},
  @{N='Used(GB)';E={ '{0:N2}' -f (($_.Size-$_.FreeSpace)/1GB) }},
  @{N='PercentFree';E={ '{0:P2}' -f ($_.FreeSpace/$_.Size) }},
  @{N='PercentUsed';E={ '{0:P2}' -f (($_.Size-$_.FreeSpace)/$_.Size) }},
  @{N='Flag';E={if($_.FreeSpace/$_.Size -lt .10){'*'}else{'-'}}} |
 Format-Table -AutoSize | out-string -Width 4096  > "$server.txt"
}


http://techwithmike.com


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>