Azure VM creation date



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








4















Is there any Management API to find Azure VM creation date? There is Get hosted service properties API for Cloud service creation date but we are not able to find out Azure VM creation date.










share|improve this question




























    4















    Is there any Management API to find Azure VM creation date? There is Get hosted service properties API for Cloud service creation date but we are not able to find out Azure VM creation date.










    share|improve this question
























      4












      4








      4


      1






      Is there any Management API to find Azure VM creation date? There is Get hosted service properties API for Cloud service creation date but we are not able to find out Azure VM creation date.










      share|improve this question














      Is there any Management API to find Azure VM creation date? There is Get hosted service properties API for Cloud service creation date but we are not able to find out Azure VM creation date.







      azure






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 6 '13 at 9:20









      user2044374user2044374

      112212




      112212






















          6 Answers
          6






          active

          oldest

          votes


















          2














          1. You can see the creation date was included in disk name on the Dashboard.
            enter image description here



          2. Also you could use Azure Powershell Command to retrieve this:



            Get-AzureVM -ServiceName myubuntu1 | Get-AzureOSDisk | select MediaLink






          share|improve this answer
































            1














            We can retrieve operation system disk file creation time in Blob storage which equivalent to virtual machine creation time. see more https://social.msdn.microsoft.com/forums/azure/en-US/3da7750a-1a7d-4c62-b58a-a4b427b2520d/get-azure-vm-creationprovision-date






            share|improve this answer






























              1














              2016 update: There still isn't a way to quickly get VM creation date in a reliable way (no, the date portion of the disk name is not reliable).






              share|improve this answer






























                1














                I recently wrote a function for this sort of thing you may find useful.



                The function only requires your tenantID and an identity that has the right permissions and will return the data you're after regarding creation date of Azure VMs, the resource groups they are in, OS and SKU.



                Here is the function:



                Function Get-AZVMCreated 
                <#
                .SYNOPSIS
                Function "Get-AZVMCreated" will connect to a given tenant and parse through the subscriptions and output Azure VM details based on creation date.

                .DESCRIPTION
                Author: Pwd9000 (Pwd9000@hotmail.co.uk)
                PSVersion: 5.1

                The user must specify the TenantId when using this function.
                The function will request access credentials and connect to the given Tenant.
                Granted the identity used has the required access permisson the function will parse through all subscriptions
                and gather data on Azure Vms based on the creation date.

                .EXAMPLE
                Get-AZVMCreated -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

                .PARAMETER TenantId
                A valid Tenant Id object. e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <String>
                #>

                [CmdletBinding()]
                param(
                [Parameter(Mandatory = $True,
                ValueFromPipeline = $True,
                HelpMessage = 'Please specify the tenant id? e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"')]
                [string]$TenantId
                )

                #------------------------------------------------Obtain Credentials for Session------------------------------------------------------------
                $Credential = Get-Credential

                #---------------------------------------------Get all Subscription Ids for given Tenant----------------------------------------------------
                $SubscriptionIds = (Get-AzureRmSubscription -TenantId $TenantId).Id

                #-------------------------------------------------Create Empty Table to capture data-------------------------------------------------------
                $Table = @()

                Foreach ($Subscription in $SubscriptionIds)
                Select-Object Name, ManagedBy, Resourcegroupname, TimeCreated
                $UniqueVMs = $Table


                You can then call and use the function like this for example:



                $TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                $AZVMsAll = Get-AZVMCreated -TenantId $TenantId | sort-object -property Created
                $Win10 = $AZVMsAll | Where-Object $_.SKU -like "*Windows-10*" | sort-object -property Created
                $Win8 = $AZVMsAll | Where-Object $_.SKU -like "*Win81*" | sort-object -property Created
                $Win7 = $AZVMsAll | Where-Object $_.SKU -like "*Win7*" | sort-object -property Created
                $Server2008R2 = $AZVMsAll | Where-Object $_.SKU -like "*2008-R2*" | sort-object -property Created
                $Server2012R2 = $AZVMsAll | Where-Object $_.SKU -like "*2012-R2*" | sort-object -property Created
                $Server2016 = $AZVMsAll | Where-Object $_.SKU -like "*2016*" | sort-object -property Created
                $RHEL = $AZVMsAll | Where-Object $_.OperatingSystem -like "*RHEL*" | sort-object -property Created
                $Ubuntu = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Ubuntu*" | sort-object -property Created
                $Centos = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Centos*" | sort-object -property Created

                $AZVMsAll


                In the above example you can also call other versions of OS's using the variable defined e.g. For all Win7 machines you can call variable $Win7 etc etc etc...






                share|improve this answer

























                • Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                  – Pwd9000
                  Nov 16 '18 at 23:53


















                0














                Use below az commands to get the disk creation date...From this OS Disk creation, we can find the VM provision date:



                diskquery='[*].Resourceid:id, name:name, timeCreated:timeCreated'
                az disk list --query "$diskquery"





                share|improve this answer
































                  -1














                  There isn't a way to get this via the Windows Azure APIs that I'm aware of. Are you trying to remotely get this value, or get it for use on the instance?



                  If you are on the instance you might try to get it based on WMI. Here it is in PowerShell, but you can adapt to C#, VB.NET, or another Scripting language that can get at the WMI info.



                  [reflection.Assembly]::LoadWithPartialName("system.management")
                  $wmiSearch = new-object -type System.Management.ManagementObjectSearcher -Arg "Select * from Win32_OperatingSystem"
                  $data = $wmiSearch.Get()
                  [System.Management.ManagementDateTimeConverter]::ToDateTime($data.InstallDate)


                  I tried this on an Azure VM and it returned basically the creation of the VM to me. You might want to test this result over time though. Also, this would only get you the time in which the VM was actually spun up. So, if you have an instance A that is running along well, then the hard drive faults on it and the Fabric Controller moves the instance to another location in the DC and spins it back up then the install date will likely be the time it was moved. This may be exactly what you are looking for, or maybe not depending on your requirements.






                  share|improve this answer























                    Your Answer






                    StackExchange.ifUsing("editor", function ()
                    StackExchange.using("externalEditor", function ()
                    StackExchange.using("snippets", function ()
                    StackExchange.snippets.init();
                    );
                    );
                    , "code-snippets");

                    StackExchange.ready(function()
                    var channelOptions =
                    tags: "".split(" "),
                    id: "1"
                    ;
                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                    StackExchange.using("externalEditor", function()
                    // Have to fire editor after snippets, if snippets enabled
                    if (StackExchange.settings.snippets.snippetsEnabled)
                    StackExchange.using("snippets", function()
                    createEditor();
                    );

                    else
                    createEditor();

                    );

                    function createEditor()
                    StackExchange.prepareEditor(
                    heartbeatType: 'answer',
                    autoActivateHeartbeat: false,
                    convertImagesToLinks: true,
                    noModals: true,
                    showLowRepImageUploadWarning: true,
                    reputationToPostImages: 10,
                    bindNavPrevention: true,
                    postfix: "",
                    imageUploader:
                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                    allowUrls: true
                    ,
                    onDemand: true,
                    discardSelector: ".discard-answer"
                    ,immediatelyShowMarkdownHelp:true
                    );



                    );













                    draft saved

                    draft discarded


















                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15849126%2fazure-vm-creation-date%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown

























                    6 Answers
                    6






                    active

                    oldest

                    votes








                    6 Answers
                    6






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes









                    2














                    1. You can see the creation date was included in disk name on the Dashboard.
                      enter image description here



                    2. Also you could use Azure Powershell Command to retrieve this:



                      Get-AzureVM -ServiceName myubuntu1 | Get-AzureOSDisk | select MediaLink






                    share|improve this answer





























                      2














                      1. You can see the creation date was included in disk name on the Dashboard.
                        enter image description here



                      2. Also you could use Azure Powershell Command to retrieve this:



                        Get-AzureVM -ServiceName myubuntu1 | Get-AzureOSDisk | select MediaLink






                      share|improve this answer



























                        2












                        2








                        2







                        1. You can see the creation date was included in disk name on the Dashboard.
                          enter image description here



                        2. Also you could use Azure Powershell Command to retrieve this:



                          Get-AzureVM -ServiceName myubuntu1 | Get-AzureOSDisk | select MediaLink






                        share|improve this answer















                        1. You can see the creation date was included in disk name on the Dashboard.
                          enter image description here



                        2. Also you could use Azure Powershell Command to retrieve this:



                          Get-AzureVM -ServiceName myubuntu1 | Get-AzureOSDisk | select MediaLink







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 22 '16 at 3:00

























                        answered Jan 21 '16 at 9:33









                        StevenSteven

                        68439




                        68439























                            1














                            We can retrieve operation system disk file creation time in Blob storage which equivalent to virtual machine creation time. see more https://social.msdn.microsoft.com/forums/azure/en-US/3da7750a-1a7d-4c62-b58a-a4b427b2520d/get-azure-vm-creationprovision-date






                            share|improve this answer



























                              1














                              We can retrieve operation system disk file creation time in Blob storage which equivalent to virtual machine creation time. see more https://social.msdn.microsoft.com/forums/azure/en-US/3da7750a-1a7d-4c62-b58a-a4b427b2520d/get-azure-vm-creationprovision-date






                              share|improve this answer

























                                1












                                1








                                1







                                We can retrieve operation system disk file creation time in Blob storage which equivalent to virtual machine creation time. see more https://social.msdn.microsoft.com/forums/azure/en-US/3da7750a-1a7d-4c62-b58a-a4b427b2520d/get-azure-vm-creationprovision-date






                                share|improve this answer













                                We can retrieve operation system disk file creation time in Blob storage which equivalent to virtual machine creation time. see more https://social.msdn.microsoft.com/forums/azure/en-US/3da7750a-1a7d-4c62-b58a-a4b427b2520d/get-azure-vm-creationprovision-date







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Aug 7 '15 at 9:17









                                Xiao WangXiao Wang

                                112




                                112





















                                    1














                                    2016 update: There still isn't a way to quickly get VM creation date in a reliable way (no, the date portion of the disk name is not reliable).






                                    share|improve this answer



























                                      1














                                      2016 update: There still isn't a way to quickly get VM creation date in a reliable way (no, the date portion of the disk name is not reliable).






                                      share|improve this answer

























                                        1












                                        1








                                        1







                                        2016 update: There still isn't a way to quickly get VM creation date in a reliable way (no, the date portion of the disk name is not reliable).






                                        share|improve this answer













                                        2016 update: There still isn't a way to quickly get VM creation date in a reliable way (no, the date portion of the disk name is not reliable).







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Jan 27 '16 at 19:44









                                        jdc0589jdc0589

                                        5,48652638




                                        5,48652638





















                                            1














                                            I recently wrote a function for this sort of thing you may find useful.



                                            The function only requires your tenantID and an identity that has the right permissions and will return the data you're after regarding creation date of Azure VMs, the resource groups they are in, OS and SKU.



                                            Here is the function:



                                            Function Get-AZVMCreated 
                                            <#
                                            .SYNOPSIS
                                            Function "Get-AZVMCreated" will connect to a given tenant and parse through the subscriptions and output Azure VM details based on creation date.

                                            .DESCRIPTION
                                            Author: Pwd9000 (Pwd9000@hotmail.co.uk)
                                            PSVersion: 5.1

                                            The user must specify the TenantId when using this function.
                                            The function will request access credentials and connect to the given Tenant.
                                            Granted the identity used has the required access permisson the function will parse through all subscriptions
                                            and gather data on Azure Vms based on the creation date.

                                            .EXAMPLE
                                            Get-AZVMCreated -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

                                            .PARAMETER TenantId
                                            A valid Tenant Id object. e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <String>
                                            #>

                                            [CmdletBinding()]
                                            param(
                                            [Parameter(Mandatory = $True,
                                            ValueFromPipeline = $True,
                                            HelpMessage = 'Please specify the tenant id? e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"')]
                                            [string]$TenantId
                                            )

                                            #------------------------------------------------Obtain Credentials for Session------------------------------------------------------------
                                            $Credential = Get-Credential

                                            #---------------------------------------------Get all Subscription Ids for given Tenant----------------------------------------------------
                                            $SubscriptionIds = (Get-AzureRmSubscription -TenantId $TenantId).Id

                                            #-------------------------------------------------Create Empty Table to capture data-------------------------------------------------------
                                            $Table = @()

                                            Foreach ($Subscription in $SubscriptionIds)
                                            Select-Object Name, ManagedBy, Resourcegroupname, TimeCreated
                                            $UniqueVMs = $Table


                                            You can then call and use the function like this for example:



                                            $TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                                            $AZVMsAll = Get-AZVMCreated -TenantId $TenantId | sort-object -property Created
                                            $Win10 = $AZVMsAll | Where-Object $_.SKU -like "*Windows-10*" | sort-object -property Created
                                            $Win8 = $AZVMsAll | Where-Object $_.SKU -like "*Win81*" | sort-object -property Created
                                            $Win7 = $AZVMsAll | Where-Object $_.SKU -like "*Win7*" | sort-object -property Created
                                            $Server2008R2 = $AZVMsAll | Where-Object $_.SKU -like "*2008-R2*" | sort-object -property Created
                                            $Server2012R2 = $AZVMsAll | Where-Object $_.SKU -like "*2012-R2*" | sort-object -property Created
                                            $Server2016 = $AZVMsAll | Where-Object $_.SKU -like "*2016*" | sort-object -property Created
                                            $RHEL = $AZVMsAll | Where-Object $_.OperatingSystem -like "*RHEL*" | sort-object -property Created
                                            $Ubuntu = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Ubuntu*" | sort-object -property Created
                                            $Centos = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Centos*" | sort-object -property Created

                                            $AZVMsAll


                                            In the above example you can also call other versions of OS's using the variable defined e.g. For all Win7 machines you can call variable $Win7 etc etc etc...






                                            share|improve this answer

























                                            • Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                              – Pwd9000
                                              Nov 16 '18 at 23:53















                                            1














                                            I recently wrote a function for this sort of thing you may find useful.



                                            The function only requires your tenantID and an identity that has the right permissions and will return the data you're after regarding creation date of Azure VMs, the resource groups they are in, OS and SKU.



                                            Here is the function:



                                            Function Get-AZVMCreated 
                                            <#
                                            .SYNOPSIS
                                            Function "Get-AZVMCreated" will connect to a given tenant and parse through the subscriptions and output Azure VM details based on creation date.

                                            .DESCRIPTION
                                            Author: Pwd9000 (Pwd9000@hotmail.co.uk)
                                            PSVersion: 5.1

                                            The user must specify the TenantId when using this function.
                                            The function will request access credentials and connect to the given Tenant.
                                            Granted the identity used has the required access permisson the function will parse through all subscriptions
                                            and gather data on Azure Vms based on the creation date.

                                            .EXAMPLE
                                            Get-AZVMCreated -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

                                            .PARAMETER TenantId
                                            A valid Tenant Id object. e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <String>
                                            #>

                                            [CmdletBinding()]
                                            param(
                                            [Parameter(Mandatory = $True,
                                            ValueFromPipeline = $True,
                                            HelpMessage = 'Please specify the tenant id? e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"')]
                                            [string]$TenantId
                                            )

                                            #------------------------------------------------Obtain Credentials for Session------------------------------------------------------------
                                            $Credential = Get-Credential

                                            #---------------------------------------------Get all Subscription Ids for given Tenant----------------------------------------------------
                                            $SubscriptionIds = (Get-AzureRmSubscription -TenantId $TenantId).Id

                                            #-------------------------------------------------Create Empty Table to capture data-------------------------------------------------------
                                            $Table = @()

                                            Foreach ($Subscription in $SubscriptionIds)
                                            Select-Object Name, ManagedBy, Resourcegroupname, TimeCreated
                                            $UniqueVMs = $Table


                                            You can then call and use the function like this for example:



                                            $TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                                            $AZVMsAll = Get-AZVMCreated -TenantId $TenantId | sort-object -property Created
                                            $Win10 = $AZVMsAll | Where-Object $_.SKU -like "*Windows-10*" | sort-object -property Created
                                            $Win8 = $AZVMsAll | Where-Object $_.SKU -like "*Win81*" | sort-object -property Created
                                            $Win7 = $AZVMsAll | Where-Object $_.SKU -like "*Win7*" | sort-object -property Created
                                            $Server2008R2 = $AZVMsAll | Where-Object $_.SKU -like "*2008-R2*" | sort-object -property Created
                                            $Server2012R2 = $AZVMsAll | Where-Object $_.SKU -like "*2012-R2*" | sort-object -property Created
                                            $Server2016 = $AZVMsAll | Where-Object $_.SKU -like "*2016*" | sort-object -property Created
                                            $RHEL = $AZVMsAll | Where-Object $_.OperatingSystem -like "*RHEL*" | sort-object -property Created
                                            $Ubuntu = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Ubuntu*" | sort-object -property Created
                                            $Centos = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Centos*" | sort-object -property Created

                                            $AZVMsAll


                                            In the above example you can also call other versions of OS's using the variable defined e.g. For all Win7 machines you can call variable $Win7 etc etc etc...






                                            share|improve this answer

























                                            • Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                              – Pwd9000
                                              Nov 16 '18 at 23:53













                                            1












                                            1








                                            1







                                            I recently wrote a function for this sort of thing you may find useful.



                                            The function only requires your tenantID and an identity that has the right permissions and will return the data you're after regarding creation date of Azure VMs, the resource groups they are in, OS and SKU.



                                            Here is the function:



                                            Function Get-AZVMCreated 
                                            <#
                                            .SYNOPSIS
                                            Function "Get-AZVMCreated" will connect to a given tenant and parse through the subscriptions and output Azure VM details based on creation date.

                                            .DESCRIPTION
                                            Author: Pwd9000 (Pwd9000@hotmail.co.uk)
                                            PSVersion: 5.1

                                            The user must specify the TenantId when using this function.
                                            The function will request access credentials and connect to the given Tenant.
                                            Granted the identity used has the required access permisson the function will parse through all subscriptions
                                            and gather data on Azure Vms based on the creation date.

                                            .EXAMPLE
                                            Get-AZVMCreated -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

                                            .PARAMETER TenantId
                                            A valid Tenant Id object. e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <String>
                                            #>

                                            [CmdletBinding()]
                                            param(
                                            [Parameter(Mandatory = $True,
                                            ValueFromPipeline = $True,
                                            HelpMessage = 'Please specify the tenant id? e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"')]
                                            [string]$TenantId
                                            )

                                            #------------------------------------------------Obtain Credentials for Session------------------------------------------------------------
                                            $Credential = Get-Credential

                                            #---------------------------------------------Get all Subscription Ids for given Tenant----------------------------------------------------
                                            $SubscriptionIds = (Get-AzureRmSubscription -TenantId $TenantId).Id

                                            #-------------------------------------------------Create Empty Table to capture data-------------------------------------------------------
                                            $Table = @()

                                            Foreach ($Subscription in $SubscriptionIds)
                                            Select-Object Name, ManagedBy, Resourcegroupname, TimeCreated
                                            $UniqueVMs = $Table


                                            You can then call and use the function like this for example:



                                            $TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                                            $AZVMsAll = Get-AZVMCreated -TenantId $TenantId | sort-object -property Created
                                            $Win10 = $AZVMsAll | Where-Object $_.SKU -like "*Windows-10*" | sort-object -property Created
                                            $Win8 = $AZVMsAll | Where-Object $_.SKU -like "*Win81*" | sort-object -property Created
                                            $Win7 = $AZVMsAll | Where-Object $_.SKU -like "*Win7*" | sort-object -property Created
                                            $Server2008R2 = $AZVMsAll | Where-Object $_.SKU -like "*2008-R2*" | sort-object -property Created
                                            $Server2012R2 = $AZVMsAll | Where-Object $_.SKU -like "*2012-R2*" | sort-object -property Created
                                            $Server2016 = $AZVMsAll | Where-Object $_.SKU -like "*2016*" | sort-object -property Created
                                            $RHEL = $AZVMsAll | Where-Object $_.OperatingSystem -like "*RHEL*" | sort-object -property Created
                                            $Ubuntu = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Ubuntu*" | sort-object -property Created
                                            $Centos = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Centos*" | sort-object -property Created

                                            $AZVMsAll


                                            In the above example you can also call other versions of OS's using the variable defined e.g. For all Win7 machines you can call variable $Win7 etc etc etc...






                                            share|improve this answer















                                            I recently wrote a function for this sort of thing you may find useful.



                                            The function only requires your tenantID and an identity that has the right permissions and will return the data you're after regarding creation date of Azure VMs, the resource groups they are in, OS and SKU.



                                            Here is the function:



                                            Function Get-AZVMCreated 
                                            <#
                                            .SYNOPSIS
                                            Function "Get-AZVMCreated" will connect to a given tenant and parse through the subscriptions and output Azure VM details based on creation date.

                                            .DESCRIPTION
                                            Author: Pwd9000 (Pwd9000@hotmail.co.uk)
                                            PSVersion: 5.1

                                            The user must specify the TenantId when using this function.
                                            The function will request access credentials and connect to the given Tenant.
                                            Granted the identity used has the required access permisson the function will parse through all subscriptions
                                            and gather data on Azure Vms based on the creation date.

                                            .EXAMPLE
                                            Get-AZVMCreated -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

                                            .PARAMETER TenantId
                                            A valid Tenant Id object. e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" <String>
                                            #>

                                            [CmdletBinding()]
                                            param(
                                            [Parameter(Mandatory = $True,
                                            ValueFromPipeline = $True,
                                            HelpMessage = 'Please specify the tenant id? e.g: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"')]
                                            [string]$TenantId
                                            )

                                            #------------------------------------------------Obtain Credentials for Session------------------------------------------------------------
                                            $Credential = Get-Credential

                                            #---------------------------------------------Get all Subscription Ids for given Tenant----------------------------------------------------
                                            $SubscriptionIds = (Get-AzureRmSubscription -TenantId $TenantId).Id

                                            #-------------------------------------------------Create Empty Table to capture data-------------------------------------------------------
                                            $Table = @()

                                            Foreach ($Subscription in $SubscriptionIds)
                                            Select-Object Name, ManagedBy, Resourcegroupname, TimeCreated
                                            $UniqueVMs = $Table


                                            You can then call and use the function like this for example:



                                            $TenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                                            $AZVMsAll = Get-AZVMCreated -TenantId $TenantId | sort-object -property Created
                                            $Win10 = $AZVMsAll | Where-Object $_.SKU -like "*Windows-10*" | sort-object -property Created
                                            $Win8 = $AZVMsAll | Where-Object $_.SKU -like "*Win81*" | sort-object -property Created
                                            $Win7 = $AZVMsAll | Where-Object $_.SKU -like "*Win7*" | sort-object -property Created
                                            $Server2008R2 = $AZVMsAll | Where-Object $_.SKU -like "*2008-R2*" | sort-object -property Created
                                            $Server2012R2 = $AZVMsAll | Where-Object $_.SKU -like "*2012-R2*" | sort-object -property Created
                                            $Server2016 = $AZVMsAll | Where-Object $_.SKU -like "*2016*" | sort-object -property Created
                                            $RHEL = $AZVMsAll | Where-Object $_.OperatingSystem -like "*RHEL*" | sort-object -property Created
                                            $Ubuntu = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Ubuntu*" | sort-object -property Created
                                            $Centos = $AZVMsAll | Where-Object $_.OperatingSystem -like "*Centos*" | sort-object -property Created

                                            $AZVMsAll


                                            In the above example you can also call other versions of OS's using the variable defined e.g. For all Win7 machines you can call variable $Win7 etc etc etc...







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Nov 14 '18 at 14:01

























                                            answered Nov 13 '18 at 20:17









                                            Pwd9000Pwd9000

                                            417




                                            417












                                            • Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                              – Pwd9000
                                              Nov 16 '18 at 23:53

















                                            • Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                              – Pwd9000
                                              Nov 16 '18 at 23:53
















                                            Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                            – Pwd9000
                                            Nov 16 '18 at 23:53





                                            Note: I would also recommend having some sort of naming convention for the AzureRmDisk "name" parameter of the VM to contain some sort of refference to the purpose of the disk, and filter on the OSDisk e.g: Where-Object $_.name -like "*osdisk*" (add the filter on line 34 in the function). This will greatly reduce the function looking through all disks and will target the OS disk only which is what we are after.

                                            – Pwd9000
                                            Nov 16 '18 at 23:53











                                            0














                                            Use below az commands to get the disk creation date...From this OS Disk creation, we can find the VM provision date:



                                            diskquery='[*].Resourceid:id, name:name, timeCreated:timeCreated'
                                            az disk list --query "$diskquery"





                                            share|improve this answer





























                                              0














                                              Use below az commands to get the disk creation date...From this OS Disk creation, we can find the VM provision date:



                                              diskquery='[*].Resourceid:id, name:name, timeCreated:timeCreated'
                                              az disk list --query "$diskquery"





                                              share|improve this answer



























                                                0












                                                0








                                                0







                                                Use below az commands to get the disk creation date...From this OS Disk creation, we can find the VM provision date:



                                                diskquery='[*].Resourceid:id, name:name, timeCreated:timeCreated'
                                                az disk list --query "$diskquery"





                                                share|improve this answer















                                                Use below az commands to get the disk creation date...From this OS Disk creation, we can find the VM provision date:



                                                diskquery='[*].Resourceid:id, name:name, timeCreated:timeCreated'
                                                az disk list --query "$diskquery"






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Feb 13 at 23:50









                                                Elletlar

                                                1,86441625




                                                1,86441625










                                                answered Feb 13 at 17:19









                                                GopiGopi

                                                1




                                                1





















                                                    -1














                                                    There isn't a way to get this via the Windows Azure APIs that I'm aware of. Are you trying to remotely get this value, or get it for use on the instance?



                                                    If you are on the instance you might try to get it based on WMI. Here it is in PowerShell, but you can adapt to C#, VB.NET, or another Scripting language that can get at the WMI info.



                                                    [reflection.Assembly]::LoadWithPartialName("system.management")
                                                    $wmiSearch = new-object -type System.Management.ManagementObjectSearcher -Arg "Select * from Win32_OperatingSystem"
                                                    $data = $wmiSearch.Get()
                                                    [System.Management.ManagementDateTimeConverter]::ToDateTime($data.InstallDate)


                                                    I tried this on an Azure VM and it returned basically the creation of the VM to me. You might want to test this result over time though. Also, this would only get you the time in which the VM was actually spun up. So, if you have an instance A that is running along well, then the hard drive faults on it and the Fabric Controller moves the instance to another location in the DC and spins it back up then the install date will likely be the time it was moved. This may be exactly what you are looking for, or maybe not depending on your requirements.






                                                    share|improve this answer



























                                                      -1














                                                      There isn't a way to get this via the Windows Azure APIs that I'm aware of. Are you trying to remotely get this value, or get it for use on the instance?



                                                      If you are on the instance you might try to get it based on WMI. Here it is in PowerShell, but you can adapt to C#, VB.NET, or another Scripting language that can get at the WMI info.



                                                      [reflection.Assembly]::LoadWithPartialName("system.management")
                                                      $wmiSearch = new-object -type System.Management.ManagementObjectSearcher -Arg "Select * from Win32_OperatingSystem"
                                                      $data = $wmiSearch.Get()
                                                      [System.Management.ManagementDateTimeConverter]::ToDateTime($data.InstallDate)


                                                      I tried this on an Azure VM and it returned basically the creation of the VM to me. You might want to test this result over time though. Also, this would only get you the time in which the VM was actually spun up. So, if you have an instance A that is running along well, then the hard drive faults on it and the Fabric Controller moves the instance to another location in the DC and spins it back up then the install date will likely be the time it was moved. This may be exactly what you are looking for, or maybe not depending on your requirements.






                                                      share|improve this answer

























                                                        -1












                                                        -1








                                                        -1







                                                        There isn't a way to get this via the Windows Azure APIs that I'm aware of. Are you trying to remotely get this value, or get it for use on the instance?



                                                        If you are on the instance you might try to get it based on WMI. Here it is in PowerShell, but you can adapt to C#, VB.NET, or another Scripting language that can get at the WMI info.



                                                        [reflection.Assembly]::LoadWithPartialName("system.management")
                                                        $wmiSearch = new-object -type System.Management.ManagementObjectSearcher -Arg "Select * from Win32_OperatingSystem"
                                                        $data = $wmiSearch.Get()
                                                        [System.Management.ManagementDateTimeConverter]::ToDateTime($data.InstallDate)


                                                        I tried this on an Azure VM and it returned basically the creation of the VM to me. You might want to test this result over time though. Also, this would only get you the time in which the VM was actually spun up. So, if you have an instance A that is running along well, then the hard drive faults on it and the Fabric Controller moves the instance to another location in the DC and spins it back up then the install date will likely be the time it was moved. This may be exactly what you are looking for, or maybe not depending on your requirements.






                                                        share|improve this answer













                                                        There isn't a way to get this via the Windows Azure APIs that I'm aware of. Are you trying to remotely get this value, or get it for use on the instance?



                                                        If you are on the instance you might try to get it based on WMI. Here it is in PowerShell, but you can adapt to C#, VB.NET, or another Scripting language that can get at the WMI info.



                                                        [reflection.Assembly]::LoadWithPartialName("system.management")
                                                        $wmiSearch = new-object -type System.Management.ManagementObjectSearcher -Arg "Select * from Win32_OperatingSystem"
                                                        $data = $wmiSearch.Get()
                                                        [System.Management.ManagementDateTimeConverter]::ToDateTime($data.InstallDate)


                                                        I tried this on an Azure VM and it returned basically the creation of the VM to me. You might want to test this result over time though. Also, this would only get you the time in which the VM was actually spun up. So, if you have an instance A that is running along well, then the hard drive faults on it and the Fabric Controller moves the instance to another location in the DC and spins it back up then the install date will likely be the time it was moved. This may be exactly what you are looking for, or maybe not depending on your requirements.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Apr 6 '13 at 12:44









                                                        MikeWoMikeWo

                                                        9,83612636




                                                        9,83612636



























                                                            draft saved

                                                            draft discarded
















































                                                            Thanks for contributing an answer to Stack Overflow!


                                                            • Please be sure to answer the question. Provide details and share your research!

                                                            But avoid


                                                            • Asking for help, clarification, or responding to other answers.

                                                            • Making statements based on opinion; back them up with references or personal experience.

                                                            To learn more, see our tips on writing great answers.




                                                            draft saved


                                                            draft discarded














                                                            StackExchange.ready(
                                                            function ()
                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15849126%2fazure-vm-creation-date%23new-answer', 'question_page');

                                                            );

                                                            Post as a guest















                                                            Required, but never shown





















































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown

































                                                            Required, but never shown














                                                            Required, but never shown












                                                            Required, but never shown







                                                            Required, but never shown







                                                            Popular posts from this blog

                                                            𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                                                            Edmonton

                                                            Crossroads (UK TV series)