Posted by: Richard Siddaway
PowerShell v2, Registry
I recently needed to look at the time service configuration on a number of machines. We can use what we have learned about reading registry keys with WMI to do this
$HKLM = 2147483650 #HKEY_LOCAL_MACHINE
$reg = [wmiclass]‘\\.\root\default:StdRegprov’
$key = "SYSTEM\CurrentControlSet\Services\W32Time\Config"
$key = "SYSTEM\CurrentControlSet\Services\W32Time\Parameters"
Set the constant for HKLM hive and create a WMI object. I’ve used the local machine but change the string to
‘\\computer_name\root\default:StdRegProv’ if you want to access a remote machine.
We then set the key and the value we want to read and call the appropriate method. As a finished I’ve displayed the data in a nicely formatted table. The maximum negative and positive values are given in seconds so I’ve converted them to hours to be more understandable.