header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Working script breaks
Last Post 13 Nov 2008 02:42 PM by SynJunkie. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
SynJunkieUser is Offline
New Member
New Member
Posts:97
Avatar

--
13 Nov 2008 11:39 AM  

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

aleksandarUser is Offline
New Member
New Member
Posts:11
Avatar

--
13 Nov 2008 01:40 PM  
For some reason, it can't contact the WMI service on one of remote machines in $servers variable. Most likely one of your servers is offline. You could check with WBEMtest to exclude PowersHell as the cause of the problem. Also, you should check the availability of the servers (filter only alive ones) before you run get-wmiobject. You could find more details here:

http://powershellcommunity.org/Forums/tabid/54/forumid/1/tpage/1/view/topic/postid/56/Default.aspx

http://powershellcommunity.org/Forums/tabid/54/forumid/1/tpage/1/view/topic/postid/513/Default.aspx

-aleksandar
http://powershellers.blogspot.com
SynJunkieUser is Offline
New Member
New Member
Posts:97
Avatar

--
13 Nov 2008 02:42 PM  
Thanks Aleksandar, i'll check out the links.

Just to re-iterate though, I can query WMI on each server if I only one server at a time. The issuue seems to be apparent when querying servers stored in an array.
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer