Maybe when you are planning to do some upgrades but don’t remember when you set your reboot schedule times on your Delivery Groups. This will show you all the reboot schedules you have configured with server names. This also shows if you have Delivery Groups with no servers assigned to them, but had previously created a reboot schedule.
Update: I did run into an interesting thing with it. I had to define the if and elseif in order for it to evaluate as being true. Not sure what was going on with that.
# Script to get reboot schedules of Delivery Groups with times and server names using ISE 5.1 and Citrix Studio SDK installed locally.
asnp Citrix*
$date = Get-Date -Format MMddyyyy
$adminAddress = "ddc.fqdn:80"
$ctxRebootSchedule = Get-BrokerRebootScheduleV2 -AdminAddress $adminAddress -MaxRecordCount 100000
$report = @()
foreach($ctx in $ctxRebootSchedule) {
$line = "" | Select-Object DesktopGroupName, ScheduleName, Enabled, Frequency, StartTime, RebootDuration, ServerCount, ServerNames
$machineNames = Get-BrokerMachine -AdminAddress $adminAddress -DesktopGroupName $ctx.DesktopGroupName
$line.DesktopGroupName = $ctx.DesktopGroupName
$line.ScheduleName = $ctx.Name
$line.Enabled = $ctx.Enabled
$line.Frequency = $ctx.Frequency
$line.StartTime = $ctx.StartTime
$line.RebootDuration = $ctx.RebootDuration
$line.ServerCount = ($machineNames.HostedMachineName).count
if(($line.ServerCount) -ne 0){
$line.ServerNames = ($machineNames.HostedMachineName) -join ';'
}
elseif(($line.ServerCount) -eq 0) {
$line.ServerNames = "None Assigned To DG"
}
$report += $line
}
$report | export-csv c:\scripts\logs\$date-Citrix-Reboot-Schedule.csv -Append -NoTypeInformation
Leave a Reply