mardi 9 mai 2017

Is timezone true or false

I want to prompt the user for a timezone. Then if the server is set to that timezone return true, if not false. I cannot figure out why my code ALWAYS returns false...

Thanks in advance!

cls

$InTimeZone = Read-Host -Promt "What Time Zone should this server be in?"

$HostName = $env:Computername

$ServerInfo = Get-WmiObject -Class win32_timezone -ComputerName $HostName

$TimeZone = $ServerInfo.Caption 

If ($InTimeZone -like $TimeZone ){$ResTimeZone = "Validation Passed: Server time zone is $TimeZone"}
Else {$ResTimeZone = "Nope."}

$TimeZone

$ResTimeZone

Aucun commentaire:

Enregistrer un commentaire