Hi
All of a sudden when running a script to get server diskspace I get the following error:
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At H:\Scripts\Get-Diskspace.ps1:8 char:5
+ gwmi <<<< -query "SELECT SystemName,Caption,VolumeName,Size,Freespace FROM win32_logicaldisk WHERE DriveType=3" -com
puter $Servers |
Here's the Script:
#Gets diskspace from a given list and outputs to a csv file.
Cls
$Results = Read-host "Where do you want to save the file? (name and path please)"
$list = Read-Host "Enter filename of server list"
$Servers = (gc $list)
Write-Host "Please wait. This may take some time. I am checking disk space on $Servers"
gwmi -query "SELECT SystemName,Caption,VolumeName,Size,Freespace FROM win32_logicaldisk WHERE DriveType=3" -computer $Servers |
Select-Object SystemName,Caption,VolumeName,@{Name="Size(GB)"; Expression={"{0:N2}" -f ($_.Size/1GB)}},@{Name="Freespace(GB)"; Expression={"{0:N2}" -f ($_.Freespace/1GB)}}, @{n="% Free";e={"{0:P2}" -f ([long]$_.FreeSpace/[long]$_.Size)}} |
sort "% Free" |
export-csv $Results
Write-Host "Finished. Your results are stored in $Results"
The script hasn't changed, and if I amend the script to point to just one server It works fine. Could anyone see why this may be as I'm really stuck!
Thanks
Lee