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
Upgraded my Modules to the latest versions and the script fails to see tagged objects and then Shutdown or Turn them on. Using the versions of the earlier Azure modules that exist when creating Automation accounts work as a workaround, for the moment.
The text was updated successfully, but these errors were encountered:
If you are getting the below message even though the VMs are tagged:
"Not tagged for shutdown directly or via membership in a tagged resource group. Skipping this VM."
I got this working by changing the following 4 lines from:
$taggedResourceGroups = @(Get-AzureRmResourceGroup | where {$.Tags.Count -gt 0 -and $.Tags.Name -contains "AutoShutdownSchedule"})
if($vm.ResourceType -eq "Microsoft.Compute/virtualMachines" -and $vm.Tags -and $vm.Tags.Name -contains "AutoShutdownSchedule")
$schedule = ($vm.Tags | where Name -eq "AutoShutdownSchedule")["Value"]
$schedule = ($parentGroup.Tags | where Name -eq "AutoShutdownSchedule")["Value"]
I also had to update the code for the vm tag detection to:
# Check for direct tag or group-inherited tag
if($vm.ResourceType -like "Microsoft.*/virtualMachines" -and $vm.Tags.AutoShutdownSchedule -gt 0)
{
# VM has direct tag (possible for resource manager deployment model VMs). Prefer this tag schedule.
$schedule = $vm.Tags.AutoShutdownSchedule
Write-Output "[$($vm.Name)]: Found direct VM schedule tag with value: $schedule"
Upgraded my Modules to the latest versions and the script fails to see tagged objects and then Shutdown or Turn them on. Using the versions of the earlier Azure modules that exist when creating Automation accounts work as a workaround, for the moment.
The text was updated successfully, but these errors were encountered: