Forum Discussion
nareshunik86
Oct 30, 2020Copper Contributor
Get date,time and timezone
I am looking for a script to get date,time, timezone from multiple remote servers (3000) using power shell. Please help me to get script.
Nov 08, 2020
Hi nareshunik86,
Could you try that PowerShell script?
$ComputerNames = Get-Content "C:\Servers.txt"
foreach($ComputerName in $ComputerNames)
{
$TimeZone=Get-WmiObject -Class win32_timezone -ComputerName $ComputerName
$LocalTime = Get-WmiObject -Class win32_localtime -ComputerName $ComputerName
$Output =@{'ComputerName' = $LocalTime.__SERVER;
'Time Zone' = $TimeZone.Caption;
'Current Time' = (Get-Date -Day $LocalTime.Day -Month $LocalTime.Month);
}
$Object = New-Object -TypeName PSObject -Property $Output
Write-Output $Object
}
Servers.txt is a text file which includes your servers' names.
AKM_GT67
Mar 16, 2022Copper Contributor