Skip to content

Instantly share code, notes, and snippets.

@daveselias
Created March 15, 2014 23:25
Function Get-TimeZone {
Param(
[Parameter(Mandatory=$True,Position=1)]
[Array]$ComputerName
)
$AllTime=@()
ForEach ($Computer in $ComputerName ) {
IF((gwmi -class Win32_SystemTimeZone -ComputerName $Computer -ErrorAction SilentlyContinue) -gt $null){
$Time = (Get-Time $Computer)
$Zone1 = (gwmi -class Win32_SystemTimeZone -ComputerName $Computer).setting
$Zone = $Zone1.split('=')[-1]
$obj=New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "ServerName" -Value $Time.ServerName
$obj | Add-Member -MemberType NoteProperty -Name "DateTime" -Value $Time.DateTime
$obj | Add-Member -MemberType NoteProperty -Name "TimeZone" -Value $Zone
$AllTime += $obj
}ELSE{
Write-Output "Your current Credentials do not have access to this system ($Computer)"
}
}
IF($AllTime.count -gt 0){
Write-Output $AllTime
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment