Bulk Edit NTP servers in vSphere using PowerCLI

Props to the following blog on these steps.  He did a great write up.
Bulk configure NTP for vSphere hosts using PowerCLI

Whether you need to bulk edit or enable NTP on your hosts the following script will do the job through PowerCLI

First connect to your vcenter using PowerCLI.  Once that is done run the following lines of code.  Replace time1 and time2 with appropriate IP or fully qualified names for your domain.  This will set the NTP server and start the services.

Get-VMHost | Add-VMHostNtpServer time1-FQDN
Get-VMHost | Add-VMHostNtpServer time2-FQDN
Get-VMHost | Get-VMHostFirewallException | where {$_.Name -eq “NTP client”} | Set-VMHostFirewallException -Enabled:$true
Get-VMHost | Get-VmHostService | Where-Object {$_.key -eq “ntpd”} | Start-VMHostService
Get-VMhost | Get-VmHostService | Where-Object {$_.key -eq “ntpd”} | Set-VMHostService -policy “automatic”


PowerShell to find recently changed accounts

There is so much a sysadmin can do with PowerShell.  This is some code I captured from someone’s site  on seeing what accounts have been changed in the last -x days.  Simply change the value after AddDays to the time frame you want – this will give you all accounts that have changed within that window.

Get-ADUser -LDAPFilter {(useraccountcontrol:1.2.840.113556.1.4.803:=2)} -Properties whenChanged | Where-Object {$_.whenChanged -gt (Get-Date).AddDays(-3)} | Select-Object Name, whenChanged

I’ll try to do better in the future with ping backs, but for this post – sorry dude who I got this from – you will be unknown.


This is the post excerpt.

I’ll be using the blog to document hints and tricks I’ve found / created / used over the years.  I’ve been focusing on vmware and sharepoint for the past 5 years working in IT.  It about time I get some of these things off of notes and into somewhere more flexible.