is there a Powershell script to list last reboot of vm's under a Azure Subscription? result maybe displayed in the ps or in a file.
Asked
Active
Viewed 298 times
1 Answers
0
If data from the last 90 days would be sufficient you could get the information from the Activity Log.
Get-AzActivityLog -ResourceGroupName resource_group_name -StartTime (Get-Date).AddDays(-90) | Where-Object {$_.OperationName -eq "Restart Virtual Machine" -or $_.OperationName -eq "Start Virtual Machine" -or $_.OperationName -eq "Deallocate Virtual Machine"} | Select-Object ResourceId,EventTimestamp,OperationName,Caller
This would query the information on a resource group not subscription level though. You could export the information to CSV by adding | Export-Csv .\file_name.csv
at the end of the command.

holger
- 788
- 6
- 8