waar is de beste plaats om te kopen van voorschrift brillen http://hollandpillen.com/lorazepam/ beste otc koud geneeskunde
Jeff Wouters's Blog

PowerShell function to get time server NTP settings from clients

by on Sep.06, 2013, under DuPSUG, PowerShell, Windows, Windows Server

Some time ago I was asked to write a PowerShell script to do an inventory of the time server (NTP) configuration on clients.
Today I was asked the same, so I grabbed my old script, expanded it a little and here you go 🙂

function Get-TimeServer {
	Gets the time server as configured on a computer.
	Gets the time server as configured on a computer.
	The default is localhost but can be used for remote computers.
	Get-TimeServer -ComputerName "Server1"
	Get-TimeServer -ComputerName "Server1","Server2"
	Get-TimeServer -Computer "Server1","Server2"
	Get-TimeServer "Server1","Server2"
	Written by Jeff Wouters.
	param ( 
	begin {
		$HKLM = 2147483650
	process {
		foreach ($Computer in $ComputerName) {
			$TestConnection = Test-Connection -ComputerName $Computer -Quiet -Count 1
			$Output = New-Object -TypeName psobject
			$Output | Add-Member -MemberType 'NoteProperty' -Name 'ComputerName' -Value $Computer
            $Output | Add-Member -MemberType 'NoteProperty' -Name 'TimeServer' -Value "WMI Error"
			$Output | Add-Member -MemberType 'NoteProperty' -Name 'Type' -Value "WMI Error"
			if ($TestConnection) {				
				try {
                    $reg = [wmiclass]"\\$Computer\root\default:StdRegprov"
				    $key = "SYSTEM\CurrentControlSet\Services\W32Time\Parameters"
				    $servervalue = "NtpServer"
				    $server = $reg.GetStringValue($HKLM, $key, $servervalue)
				    $ServerVar = $server.sValue -split ","
				    $Output.TimeServer = $ServerVar[0]
    				$typevalue = "Type"
                    $type = $reg.GetStringValue($HKLM, $key, $typevalue)
                    $Output.Type = $Type.sValue				
                } catch {
			} else {

6 Comments for this entry

Leave a Reply