The code around getting the VMs and start the VMs could look like this:
# Get basic variables
$day = Get-AutomationVariable -Name 'WVDdayofweek'
$week = Get-AutomationVariable -Name 'WVDweek'
$WVDgroupTag = $week
# Just some output
Write-Output "Current Day is $day"
Write-Output "Current Week is $week"
# Add your code to get and start all VMs with Tag WVDgroup = x here
Write-Output "Starting WVD host of WVDhostgroup = $WVDgroupTag"
########################################
# Prepare and set variables for next run
if ($day -lt 7) {
$day += 1
Set-AutomationVariable -Name 'WVDdayofweek' -Value $day
}
else {
$day = 1
Set-AutomationVariable -Name 'WVDdayofweek' -Value $day
if ($week -lt 4) {
$week += 1
Set-AutomationVariable -Name 'WVDweek' -Value $week
}
else {
$week = 1
Set-AutomationVariable -Name 'WVDweek' -Value $week
}
}
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten