Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
4,924 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm trying to get value of decommission tag for all resources in my subscriptions.
Hi @Bhavishka Sathawane ,
maybe these 2 scripts are helpful to get started.
Get Azure VMs:
$vm = Get-AzVM
$vm | ForEach-Object {
if ($($_.Tags.decommission)) {
$DecommissionDate = $_.Tags.decommission
Write-Output "DecomissionDate for $($_.Name) = $DecommissionDate"
}
else { Write-Output "DecomissionDate for $($_.Name) is unknown" }
}
Get All Azure Resources:
$resources = Get-AzResource
$resources | ForEach-Object {
if ($($_.Tags.decommission)) {
$DecommisssionDate = $_.Tags.decommission
Write-Output "DecomissionDate for $($_.Name) = $DecommissionDate"
}
else { Write-Output "DecomissionDate for $($_.Name) is unknown" }
}
The variable `$DecommissionDate contains the value as a string.
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten