Raj Nadar
Raj Nadar

Reputation: 31

How to check the Last Start of the server from Azure Console

I have around 100 servers in Azure. These Servers are used for DEV & UAT environments. I want to check when these servers were last running. Then I can decide which servers to keep in Azure, and delete one if it's not in use.

Upvotes: 0

Views: 1435

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30025

Please correct me if I misunderstand you.

Assume you have 100 azure vms(in one resource group) in running state, you want to check which vm is the last start one.

You can check the vm's Provisioning time, then add vm and provision time to a dictionary, then sort them by time.

$vms = Get-AzVM -ResourceGroupName "xxx"
$vm_info=@{}

foreach($vm in $vms){

 $v1 = Get-AzVM -ResourceGroupName "xxx" -Name $vm.name -Status
 $vm_info.add($vm.name,$v1.Statuses[0].Time)

 }

#here, you can add your own code to sort the dictionary of $vm_info, like below:

$vm_info.GetEnumerator() | Sort-Object -Property value | select -Last 1

Upvotes: 0

Related Questions