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.
Please help me to get script.
3 Replies
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_GT67Copper Contributor
- farismalaebIron Contributor
Hi
Try to make a look on WMI
this is the powershell query to get the date and time from remote computer
Get-WmiObject -ComputerName REMOTE_COMPUTER -Query 'select * from Win32_CurrentTime where __CLASS ="Win32_LocalTime"'For the timezone, you can use TZUTIL