Skip to content

Instantly share code, notes, and snippets.

@jeffpatton1971
Created March 12, 2015 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffpatton1971/a69407bf3241c9dc4014 to your computer and use it in GitHub Desktop.
Save jeffpatton1971/a69407bf3241c9dc4014 to your computer and use it in GitHub Desktop.
This script checks the values of specific registry keys based on recommendations from Vmware for virtualized PDC Emulators.
<#
.SYNOPSIS
Check stored values of w32tm against Vmware recommendations
.DESCRIPTION
This script checks the values of specific registry keys based
on recommendations from Vmware for virtualized PDC Emulators.
For more details please see pages 5 and 6 of this Vmware white
paper (http://www.vmware.com/files/pdf/Virtualizing_Windows_Active_Directory.pdf)
.PARAMETER Type
This determines from which peers W32Time will accept
synchronization. When the REG_SZ value is changed from
NT5DS to NTP, the PDC Emulator synchronizes from the list of
reliable time servers specified in the NtpServer registry key.
.PARAMETER NtpServer
This entry specifies a space-delimited list of stratum 1 time
servers from which the local computer can obtain reliable
time stamps. The list can use either fully-qualified domain
names or IP addresses. (If DNS names are used, you must
append ,0x1 to the end of each DNS name.)
.PARAMETER AnnounceFlag
This entry controls whether the local computer is marked as
a reliable time server (which is only possible if the previous
registry entry is set to NTP as described above). Change the
REG_DWORD value from 10 to 5 here.
.EXAMPLE
Test-W32tmBPA.ps1 -Type NTP -NtpServer 'time.windows.com,0x1','tock.usno.navy.mil,0x1' -AnnounceFlag 5
.NOTES
ScriptName : Test-W32tmBPA
Created By : jspatton
Date Coded : 03/12/2015 11:20:09
.LINK
https://gist.github.com/jeffpatton1971/a69407bf3241c9dc4014
.LINK
http://www.vmware.com/files/pdf/Virtualizing_Windows_Active_Directory.pdf
#>
[CmdletBinding()]
Param
(
[string]$Type = "NTP",
[string[]]$NtpServer = ('time.windows.com,0x1','tock.usno.navy.mil,0x1'),
[int]$AnnounceFlag = 5
)
Begin
{
Write-Verbose "Get Parameters key from registry";
$Parameters = Get-Item HKLM:\System\CurrentControlSet\Services\W32Time\Parameters;
Write-Verbose "Get value of Type key";
$rType = $Parameters.GetValue("Type");
Write-Verbose "Get value of NtpServer key";
$rNtpServer = ($Parameters.GetValue("Ntpserver")).Split(" ");
Write-Verbose "Get Config key from registry";
$Config = Get-Item HKLM:\System\CurrentControlSet\Services\W32Time\Config;
Write-Verbose "Get value of AnnounceFlags key";
$rAnnounceFlags = $Config.GetValue("AnnounceFlags");
$TypeValue = $true;
$AnnounceFlagValue = $true;
$NtpServerValue = $true;
}
Process
{
Write-Verbose "Check Type stored in registry vs Type parameter";
if (!($Type -eq $rType))
{
$TypeValue = $false
}
Write-Verbose "Check AnnounceFlags in registry vs AnnounceFlag parameter";
if (!($AnnounceFlag -eq $rAnnounceFlags))
{
$AnnounceFlagValue = $false
}
Write-Verbose "Check NtpServer in registry vs NtpServer parameter";
$rNtpServer |ForEach-Object
{
if (!($NtpServer -contains $_))
{
$NtpServerValue = $false
}
}
}
End
{
if (!($TypeValue))
{
Write-Host "Invalid Type found : $($rType)";
}
if (!($AnnounceFlagValue))
{
Write-Host "Invalid AnnounceFlags found : $($rAnnounceFlags)":
}
if (!($NtpServerValue))
{
Write-Host "Invalid NtpServer found : $($rNtpServer)";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment