Using an XML for configuration to work with this script

Hi, I am constantly getting an error about the RPC server unavailable. Can you tell me what is wrong with the code on either the XML document or the ps1 script?

Xml Document:



Script (I will change it to objects at some point but for now just to get it working is key for me)

[xml]$configFile = Get-Content “C:_x\config.xml”

$ConvertToGB = (1024 * 1024 * 1024)

“Server” + “,” + “DriveLetter” + “,” + “SitesHosted” + “,” + “Size” + “,” + “Free”

foreach($config in $configFile.config.Server)
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $config.ip_address -Filter $config.partition | Select-Object Size,FreeSpace
$config.ip_address + $config.partition + $config.host_example + ([math]::round(($disk.Size / $ConvertToGB),2)) + “GB” + “,” + ([math]::round((($disk.FreeSpace / $ConvertToGB)),2)) + “GB”

having trouble pasting my xml document…
but xml is like the following

within server
there is
and hostname which is a description

RPC server unavailable means that WMI can’t make contact with the remote server. Either because it doesn’t recognise what you are trying to pass as the computername/IP address or because DCOM is disabled on the remote machine (check the Windows firewall - it blocks DCOM by default)

I’d use a CSV file rather than XML for this as you can read the CSV file and each row becomes an object

Your script is needlessly complicated - see the comments on your previous post

You also need to add error handling in your script. If a computer is offline or WMI can’t connect, you should account for that:

foreach($config in $configFile.config.Server) {
    if (Test-Connection -ComputerName $config.ip_address -Count 2 -Quiet) {
        try {
            $disk = Get-WmiObject Win32_LogicalDisk -ComputerName $config.ip_address -Filter $config.partition -ErrorAction Stop | Select-Object Size,FreeSpace
            $config.ip_address + $config.partition + $config.host_example + ([math]::round(($disk.Size / $ConvertToGB),2)) + "GB" + "," + ([math]::round((($disk.FreeSpace / $ConvertToGB)),2)) + "GB"
        catch {
            "There was a problem getting WMI information from {0}. {1}" -f $config.ip_address, $_.Exception.Message


    else {
        "{0} could not be reached (i.e. PINGed)" -f $config.ip_address

Thanks Rob and also Richard.

Another question, what if I wanted to add a status if the gigs are say over 15 gigs?
if over 15 gigs, it is “OK”
if it is less than 15 gigs then “Warning”
else below 10 gigs is “Critical”

I would suggest searching for “Powershell Storage Report”. There are a plethora of examples on how to get storage information from servers with threshold indications like you are asking