Run ESXi Commands Via PowerShell And SSH
Some ESXi CLI commands have no alternative in PowerCLI and you have to run the commands on ESXi via SSH or locally. But there is another easier way to run batch commands and get result.
You can use PLINK on this regard. Plink is one of Putty components, so you need to have plink.exe on your local drive or any location which to be accessed.
Change the below script parameters and run your commands as you like:
$User = <User> $Pswd = <Host Password> $hostName = <Host> $plink = <PLink Path> "\plink.exe" $plinkoptions = " -v -pw $Pswd" $cmd1 = ' esxcli vm process list' $remoteCommand = '"' + $cmd1 + '"' $command = "Echo Yes| "+$plink + " " + $plinkoptions + " " + $User + "@" + $hostName + " " + $remoteCommand $result = Invoke-Expression -command $command $result
[quotes_and_tips]