1

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

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.