Hello, @Veerpal Singh !
Looking for a PowerShell script that provides all the reboot logs? I would use Get-AzureDeploymentEvent or Get-CimInstance with lastbootuptime
.
Get-AzureDeploymentEvent
https://azure.microsoft.com/en-us/blog/viewing-vm-reboot-logs/
To help determine whether the reboot you observed on your Virtual Machine is due to a Planned Maintenance event, we’re introducing a new API that provides logs that show when your VM was rebooted. This can be accessed in the Portal under "View Reboot Logs" or by running the following query in PowerShell:
$today = get-date
$yest = $today.AddDays(-1)
Get-AzureDeploymentEvent -ServiceName kenaztestdemoservice -StartTime $yest -EndTime $today
Get-CimInstance
https://devblogs.microsoft.com/scripting/powertip-get-the-last-boot-time-with-powershell/
Another approach would be to use Get-CimInstance with LastBootUpTime
:
Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime
An approach used by Improve Scripting is to create a list of servers in a text file and then run the following:
https://www.improvescripting.com/get-the-last-boot-time-using-powershell-script/
Get-CimInstance -ComputerName (Get-Content -Path 'C:\Temp\servers.txt') -Class CIM_OperatingSystem -ErrorAction Stop | Select-Object CSName, LastBootUpTime | Out-GridView
Additional Options
If you are still looking for more options, Shell Geek has a pretty good list of available approaches including net statistics workstation
and system info
(optionally using /S
for server name):
https://shellgeek.com/get-last-boot-time-of-computer-using-powershell