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]

Davoud Teimouri

Davoud Teimouri is as a professional blogger, vExpert 2015/2016/2017/2018/2019, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

2 Responses

  1. 27/05/2019

    […] Run ESXi Commands Via PowerShell And SSH […]

  2. 31/05/2019

    […] Run ESXi Commands Via PowerShell And SSH […]

Leave a Reply

Your email address will not be published. Required fields are marked *