In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
What this article shares with you is the method of querying the creation record of Azure virtual machine. I believe most people have not learned this skill. In order to let you learn, I have summarized the following content. Without saying much, let's read on.
In fact, we can solve this problem directly through Azure's PowerShell. We only need to write a simple script. First, run the following command to get all the log of Azure in the past three months.
$logs = Get-AzureRmLog-ResourceProvider Microsoft.Compute-StartTime (Get-Date). AddDays (- 90)-Maxrecord 100000
Foreach ($log in $logs) {if (($log.OperationName.Value-eq 'Microsoft.Compute/virtualMachines/write')-and ($log.SubStatus.Value-eq' Created')) {Write-Output "$($log.caller) created vm $($log.Id.split (" / ") [8]) at $($log.EventTimestamp) in ResourceGroup $($log.ResourceGroupName)"}}
So you can see the record created by VM!
What if you want to aggregate this information into Excel? You can use the following code!
[pscustomobject []] $VMObjects = $nullforeach ($log in $logs) {if (($log.OperationName.Value-eq 'Microsoft.Compute/virtualMachines/write')-and ($log.SubStatus.Value-eq' Created')) {Write-Output "$($log.caller) created vm $($log.Id.split (" / ") [8]) at $($log.EventTimestamp) in ResourceGroup $($log.ResourceGroupName)" $VMObject = New- Object-TypeName psobject $VMObject | Add-Member-MemberType NoteProperty-Name SubscriptionName-Value $SubscriptionName $VMObject | Add-Member-MemberType NoteProperty-Name SubscriptionID-Value $SubscriptionID $VMObject | Add-Member-MemberType NoteProperty-Name ResourceGroup-Value $log.ResourceGroupName $VMObject | Add-Member-MemberType NoteProperty-Name VMName-Value $log.Id.split ("/") [8] $VMObject | Add-Member-MemberType NoteProperty-Name Time-Value $log.EventTimestamp $VMObjects + = $VMObject}} $OutputPath= "C:\ vm.csv" $VMObjects | Export-Csv-NoTypeInformation-LiteralPath $OutputPath
Finally, this method can only collect logs within 90 days, because the longest log open to users on the Azure platform is 90 days.
This is the end of the method of querying the creation records of the Azure virtual machine. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.