kirtyakshay
Contributor
Contributor

Script to run ntpd -p command on all hosts

Jump to solution

If I connect to a single ESXi host using SSH and run the command ntpq -p, I get the output as below :

pastedImage_1.png

I know I can get the configured NTP server and the service running status using RV Tools however I am looking for a script to pull all the details seen in the above screenshot from all the ESXi hosts in a vCenter. I am not good in scripting and still learning it.

Can anyone please help me with a script so that I can connect to the vCenter and run that to get the output in a file for all the hosts ?

Any help would be really appreciable.

Thanks in advance!

Akshay Kirty

Tags (2)
0 Kudos
23 Replies
LucD
Leadership
Leadership

Those are quite a few errors.

First let us find out what environment you are using.

Run the following

Get-Culture

$PSVersionTable

Get-Module -Name VMware.PowerCLI -ListAvailable

Did you actually install the module Posh-SSH from the PowerShell Gallery?

Do a

Get-Module -Name Posh-SSH -ListAvailable

If nothing is returned, do a

Install-Module -Name Posh-SSH -Confirm:$false -Force


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kirtyakshay
Contributor
Contributor

Seems the Posh-SSH module is not installed and the Jump box don't have the internet connectivity:

pastedImage_0.png

I have manually downloaded the .nupkg for Posh-SSH. Do i need to import it in PowerCli ?

Thanks,

Akshay

0 Kudos
LucD
Leadership
Leadership

If you place the module in one of the folders in $env:PSModulePath, then PS will find the module.

Btw, from a station with Internet connecvity you can do Save-Module.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
kirtyakshay
Contributor
Contributor

Wow....It worked, finally got what I was looking for in the report.

pastedImage_0.png

I put the extracted module in the module path, that's it.

Thank you so much....really appreciate your efforts in this, considering I didn't know much about scripting.

Thank you

Akshay Kirty

0 Kudos