Posts

Showing posts from April 19, 2018

Running CLI Commands in ESXi using plink software

Image
Get-esxcli will help us to run the CLI commands over the host directly but to extend it we cannot run certain commands directly over the host, In such case, we can use the below script to run directly on the host and achieve our goals. One shot with the script to achieve multiple targets My target was given to check the status of smartd services in each host and disable it, So I have put the commands on the variable $cmd and $cmd2 and executing it in all the machines,  which has been feed in the variable $machines , command get executed in all the hosts fed in the variable $machines . Script :  $user = '' $pswd = '' $cmd = 'etc/init.d/smartd status' $cmd2 = 'chkconfig smartd off' $machines = Get-Content "" foreach ( $MACHINE in $machines ) { Get-VMHost -Name $MACHINE | % {     $ssh = Get-VMHostService -VMHost $_ | where { $_ . Key -eq 'TSM-SSH' }     if ( ! $ssh . Running)