Reputation: 11
I am trying to write a script where I can run an EXE on a remote maching to stop processes and then reboot the server. I have everything I think I need but the output for the IP Addresses is coming up as @{ipaddress=xxx.xxx.xxx.xxx}. It is telling me there is an error in my ip address of the server. Here is what I got.
$action = "reboot"
function LoadServerList {
param([string]$sFileName);
$aServers = Import-Csv $sFileName | Where-Object { !($_.servername.StartsWith('#')) -and ($_.servername -ne ""); };
$aServers | Add-Member -MemberType NoteProperty -Name status -Value "unknown";
return $aServers;
}
$IPADDRESS = Import-Csv -path D:\Scripts\RebootSequence\LABIPAddress.csv | Where-Object { !($_.ipaddress.StartsWith('#')) -and ($_.ipaddress -ne ""); }
$CMD = 'icadmin'
$arg1 = 'tv'
$arg2 = 'admin'
$arg3 = 'admin1'
$arg4 = 'D:\Avaya\IC73\bin\icadmin.exe'
$arg5 = '$SRVIP'
& $CMD $arg1 $arg2 $arg3 $IPADDRESS $arg4
Upvotes: 1
Views: 180
Reputation: 37730
Try changing this:
$IPADDRESS = Import-Csv -path D:\Scripts\RebootSequence\LABIPAddress.csv | Where-Object { !($_.ipaddress.StartsWith('#')) -and ($_.ipaddress -ne ""); }
to this:
$IPADDRESS = Import-Csv -path D:\Scripts\RebootSequence\LABIPAddress.csv | Where-Object { !($_.ipaddress.StartsWith('#')) -and ($_.ipaddress -ne ""); } | Select-Object -Expand ipaddress
Upvotes: 2