Hi Luc ,
Thanks for pointing towards Plink. I was going through some of your's & Alan's old notes regarding executing cmds through plink.
I tried using this script for a single host & to grep the "State" status to a csv file for that particular host printing the hostname & "state" status.
Below is my script i tried to use :
$ExportFilePath = "C:\HostNicInfo.csv"
$PuttyUser = "root"
$PuttyPwd = "passwd"
$hostlist = "esx-test-120"
$Plink = "C:\plink.exe"
$PlinkOptions = " -v -batch -pw $PuttyPwd"
$cmd1 = '/opt/emc/powerpath/bin/powermt check_registration '
$RCommand = '"' + $cmd1 + '"'
$command = $Plink + " " + $PlinkOptions + " " + $PuttyUser + "@" + $hostlist + " " + $RCommand
$msg = Invoke-Expression -command $command
Write-Host "Connecting to: " $hostlist -ForegroundColor Green
$HostInfo.license = ($Message[0] -split "State: ")[1]
$Report += $HostInfo.license
$Report | Export-Csv $ExportFilePath -NoTypeInformation
The output of the $cmd1 if i execute manually gives me like this below :
Type : served (counted) State : licensed Registered To : ACTIVATED Issue Date : xx-xx-xx Feature : PowerPathMP Feature Version : 5.4 Registering Svr : xxxxxxxx License Count : xxxx Overdraft Count : xxx License Server : xxxxxxxx In the above output i tried for "State" status. But i am getting the below errors while executing the above script. Looking up host "esx-test-120" Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null. Please share your advices how to make it work because in future i want it to import a server list instead of single server. Thanks in Advance.
Connecting to 10.182.79.63 port 22
Server version: SSH-2.0-OpenSSH_5.6
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.62
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-256
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 54:d5:1a:c3:61:b0:2e:c1:43:cc:eb:06:29:2c:5c:86
Connection abandoned.
Disconnected: User aborted at host key verification
Connecting to: esx-test-120
Cannot index into a null array.
At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\abc.ps1:13 char:31
+ $HostInfo.license = ($Message[ <<<< 0] -split "State: ")[1]
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
At C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\abc.ps1:15 char:21
+ $Report | Export-Csv <<<< $ExportFilePath -NoTypeInformation
+ CategoryInfo : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand