When the Azure VM was created - Find out

It happened with me couple of times when somebody was creating noice when was this VM got created and who created the VM, i am sure even you guys looked for this information or somebody asked for. So lets find out how :-

Well Azure provides wonderful way to figure out that is Activity Logs , where we can find out when was VM got created and who created the VM but the catch is this information is available for last 90 days only. What if we need the info for more then that ?

Here is a workaround that could help us .i.e figure out the creation date of the disk and its very simple to do the with help of Powershell check it out -


get-azdisk -ResourceGroupName "yourRG" -DiskName "yourDiskname" |
 select Name, TimeCreated,@{N="VMname"; e = {($_.managedby -split "/")[8]} }


Once you run the above command modified as per your environment it would give result as below


Name                                             TimeCreated          VMname
----                                                   -----------                      ------
osdisk54454321565425         5/10/2019 1:06:23 PM   ACI-VM


above discussed method would only help if you have Managed disk but what if you also have unmanged disk. 

Well for unmanaged disk you just need to change the way its name has random no. , Yes when you create VM with unmanged disk you give the name of storage account and Azure automatically creates Container name VHD and placed os-disk in it with name containing random numbers.

These random numbers is actually the time stamp when disk was created.


like in above picture you see the unmanaged disk name is "fordisk20190711194943.vhd"  which is  actually 11 july 2019 at 7:49:43 PM.


Now check this powershell cmdlet which could help you figuring this out :


$storaccount = Get-AzStorageAccount -Name "yourstrageaccount" -ResourceGroupName "yourresourcegroup"

$osblob = Get-AzStorageBlob -Context $storaccount.Context -Container "yourcontainername" -Blob "osdiskname" 

$vmCreate = [datetime]::ParseExact(($OSBlob.Name.Substring(($OSBlob.Name.Length-18),14)),'yyyyMMddHHmmss',$null).tostring()


now $vmcreate will provide you the date and time and thats how you can figure out the unmanaged disk creation time stamp.

Please left comment below if you find something more in this regards ;)

No comments:

Post a Comment

MS Defenders

 Microsoft Defender offers a wide range of security solutions, similar to the ones we've discussed (Defender for Containers, Defender fo...