You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding base required tags to Resource (Virtual Machine):
$tags=@{
"CreatedOn"="10/14/2021""Criticality"="2""Application"="Application Name""BusinessOwner"="Full Name seperate names with /""TechnicalContact"="Full Name""PatchingWindow"="Patching Time Window""PatchingDOW"="Days of the week Patches can be applied like MTWTFSS""Compliance"="Y""Environment"="Production""IAC"="N"
}
$res=Get-AzResource-Name servername -ResourceType Microsoft.Compute/virtualMachines
New-AzTag-ResourceId $res.id-Tag $tags
Use OSDisk to estimate the CreatedOn tag for a VM
Set-Azcontext-Subscription SubscriptionName |Out-Null$vms=Get-AzVM$tagName='CreatedOn'ForEach ($vmin$vms) {
$dskInfo=get-azdisk-Name $vm.StorageProfile.OsDisk.Name$tagValue='{0:MM/dd/yyyy}'-f$dskInfo.TimeCreated$vm.NameIf ($vm.tags.Keys-contains$tagName) {
"`tTag Exists"
}
Else {
"`tWill set CreatedOn Tag for {0} on {1}"-f$vm.Name,$tagValue$vm.Tags.Add($tagName,$tagValue)
Set-AzResource-ResourceId $vm.Id-Tag $vm.tags-Force
}
}
Working on generic master list.
Other resources such as AKS can include resource specific tags