Executing shell commands remotely on multiple hosts

Recently, i was asked if we can automate esxi shell commands remotely on a large number of esxi server.

As there is no straight forward way to do it, at least not using PowerCLI, i had to try using Putty.

Plink is a command line tool that enables execution shell command on remote servers, so that was a start. The problem is that i did not want it to work interactively, because i had to accept all servers certificates (all self signed), and where is the automation in that?

Plink does not offer an option to automatically accept the certificate key, so i had to look else where.

Pscp is another command line tool that enable file copy to remote host, and this command does allow to automatically accept keys and add them to the computer cache so they can be used later with Plink.

All those files (plink,pscp) can be found here, with documentation.

And to wrap it all up i have written a short PowerShell script that uses these command line tools to restart the management agents on multiple esxi servers without prompting the user for any info.

the script is on github:

it does require a bit of tweaking for each environment.

Hope someone can benefit.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: