Skip to content

Commit 907134b

Browse files
Reboot schedule scripts
1 parent 2db07e8 commit 907134b

16 files changed

+1536
-0
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#Requires -Version 5.0
2+
3+
<#
4+
.SYNOPSIS
5+
Gets one or more reboot cycles
6+
7+
.DESCRIPTION
8+
9+
.NOTES
10+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
11+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
12+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
13+
the use and the consequences of the use of this freely available script.
14+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
15+
© ScriptRunner Software GmbH
16+
17+
.COMPONENT
18+
Requires the library script CitrixLibrary.ps1
19+
Requires PSSnapIn Citrix*
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/blob/master/Citrix/Applications
23+
24+
.Parameter SiteServer
25+
[sr-en] Specifies the address of a XenDesktop controller.
26+
This can be provided as a host name or an IP address
27+
[sr-de] Name oder IP Adresse des XenDesktop Controllers
28+
29+
.Parameter Uid
30+
[sr-en] Reboot cycle that have the specified Uid
31+
[sr-de] Neustart-Zyklus mit diese UId
32+
33+
.Parameter CatalogUid
34+
[sr-en] Gets reboot cycles that relate to the catalog with a particular Uid
35+
[sr-de] Neustart-Zyklen aus diesem Katalog
36+
37+
.Parameter RebootDuration
38+
[sr-en] Reboot cycles with the specified duration
39+
[sr-de] Neustart-Zyklen mit der angegebenen Dauer
40+
41+
.Parameter RestrictToTag
42+
[sr-en] Reboot cycles with the specified tag
43+
[sr-de] Neustart-Zyklen mit dem angegebenen Tag
44+
45+
.Parameter MachinesCompleted
46+
[sr-en] Reboot cycles that have the specified count of machines successfully rebooted during the cycle
47+
[sr-de] Neustart-Zyklen, bei denen die angegebene Anzahl von Rechnern während des Zyklus erfolgreich neu gestartet wurde
48+
49+
.Parameter MachinesFailed
50+
[sr-en] Reboot cycles that have the specified count of machines issued with reboot requests where either the request failed or the operation did not complete within the allowed time
51+
[sr-de] Neustart-Zyklen, bei denen die angegebene Anzahl von fehlerhaften Rechnern während des Zyklus
52+
53+
.Parameter MachinesInProgress
54+
[sr-en] Reboot cycles that have the specified count of machines issued with reboot requests but which have not yet completed the operation
55+
[sr-de] Neustart-Zyklen, bei denen die angegebene Anzahl von Rechner, die eine Aufforderung zum Neustart erhalten, den Vorgang aber noch nicht abgeschlossen haben
56+
57+
.Parameter MachinesPending
58+
[sr-en] Reboot cycles that have the specified count of outstanding machines to be rebooted during the cycle but on which processing has not yet started
59+
[sr-de] Neustart-Zyklen, bei denen die angegebene Anzahl von Rechner, die während des Zyklus neu gestartet werden sollen, auf denen die Verarbeitung aber noch nicht begonnen hat
60+
61+
.Parameter MachinesSkipped
62+
[sr-en] Reboot cycles that have the specified count of machines scheduled for reboot during the cycle but which were not processed either because the cycle was canceled or abandoned or because the machine was unavailable for reboot processing throughout the cycle
63+
[sr-de] Neustart-Zyklen, bei denen die angegebene Anzahl von Rechnern während des Zyklus der Neustart abgebrochen wurde
64+
65+
.Parameter IgnoreMaintenanceMode
66+
[sr-en] Reboot machines in maintenance mode
67+
[sr-de] Neustart von Maschinen im Wartungsmodus
68+
69+
.Parameter RebootScheduleName
70+
[sr-en] Reboot cycles which were triggered by the named reboot schedule
71+
[sr-de] Reboot-Zyklen, die durch den genannten Reboot-Zeitplan ausgelöst wurden
72+
#>
73+
74+
param(
75+
[string]$Uid,
76+
[string]$CatalogUid,
77+
[string]$RebootScheduleName,
78+
[bool]$IgnoreMaintenanceMode,
79+
[int]$RebootDuration,
80+
[string]$RestrictToTag,
81+
[int]$MachinesCompleted,
82+
[int]$MachinesFailed,
83+
[int]$MachinesInProgress,
84+
[int]$MachinesPending,
85+
[int]$MachinesSkipped
86+
)
87+
88+
try{
89+
StartCitrixSessionAdv -ServerName ([ref]$SiteServer)
90+
91+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
92+
'AdminAddress' = $SiteServer
93+
}
94+
95+
if([System.String]::IsNullOrWhiteSpace($Uid) -eq $false){
96+
$cmdArgs.Add('Uid',$Uid)
97+
}
98+
else{
99+
if($PSBoundParameters.ContainsKey('CatalogUid') -eq $true){
100+
$cmdArgs.Add('CatalogUid',$CatalogUid)
101+
}
102+
if($PSBoundParameters.ContainsKey('RebootScheduleName') -eq $true){
103+
$cmdArgs.Add('RebootScheduleName',$RebootScheduleName)
104+
}
105+
if($PSBoundParameters.ContainsKey('RebootDuration') -eq $true){
106+
$cmdArgs.Add('RebootDuration',$RebootDuration)
107+
}
108+
if($PSBoundParameters.ContainsKey('RestrictToTag') -eq $true){
109+
$cmdArgs.Add('RestrictToTag',$RestrictToTag)
110+
}
111+
if($MachinesCompleted -gt 0){
112+
$cmdArgs.Add('MachinesCompleted',$MachinesCompleted)
113+
}
114+
if($MachinesFailed -gt 0){
115+
$cmdArgs.Add('MachinesFailed',$MachinesFailed)
116+
}
117+
if($MachinesInProgress -gt 0){
118+
$cmdArgs.Add('MachinesInProgress',$MachinesInProgress)
119+
}
120+
if($MachinesPending -gt 0){
121+
$cmdArgs.Add('MachinesPending',$MachinesPending)
122+
}
123+
if($MachinesSkipped -gt 0){
124+
$cmdArgs.Add('MachinesSkipped',$MachinesSkipped)
125+
}
126+
127+
}
128+
129+
$ret = Get-BrokerRebootCycle @cmdArgs | Select-Object *
130+
if($SRXEnv) {
131+
$SRXEnv.ResultMessage = $ret
132+
}
133+
else{
134+
Write-Output $ret
135+
}
136+
}
137+
catch{
138+
throw
139+
}
140+
finally{
141+
CloseCitrixSession
142+
}
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
#Requires -Version 5.0
2+
3+
<#
4+
.SYNOPSIS
5+
Gets one or more reboot schedules
6+
7+
.DESCRIPTION
8+
9+
.NOTES
10+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
11+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
12+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
13+
the use and the consequences of the use of this freely available script.
14+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
15+
© ScriptRunner Software GmbH
16+
17+
.COMPONENT
18+
Requires the library script CitrixLibrary.ps1
19+
Requires PSSnapIn Citrix*
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/blob/master/Citrix/Applications
23+
24+
.Parameter SiteServer
25+
[sr-en] Specifies the address of a XenDesktop controller.
26+
This can be provided as a host name or an IP address
27+
[sr-de] Name oder IP Adresse des XenDesktop Controllers
28+
29+
.Parameter Uid
30+
[sr-en] Reboot schedule with the specified value of Uid
31+
[sr-de] Neustartzeitplan mit dieser Uid
32+
33+
.Parameter RebootScheduleName
34+
[sr-en] Reboot schedule with the specified name
35+
[sr-de] Neustartzeitplan mit dem angegebenen Namen
36+
37+
.Parameter Active
38+
[sr-en] Desktop group reboot schedules according to whether they are currently active or not
39+
[sr-de] Aktive/deaktivierte Neustartzeitpläne
40+
41+
.Parameter Enabled
42+
[sr-en] Reboot schedule with the specified value
43+
[sr-de] Neustartzeitpläne mit der angegebenen Wert
44+
45+
.Parameter Day
46+
[sr-en] Reboot schedules set to run on the specific day of week
47+
[sr-de] Neustartzeitpläne die für diesen Wochentag konfiguriert sind
48+
49+
.Parameter DayInMonth
50+
[sr-en] Reboot schedules set to run on the specific day in month
51+
[sr-de] Neustartzeitpläne die für diesen Tag konfiguriert sind
52+
53+
.Parameter DesktopGroupUid
54+
[sr-en] Reboot schedules for the desktop group having this Uid
55+
[sr-de] Neustartzeitpläne dieser Bereitstellungsgruppe
56+
57+
.Parameter MaxOvertimeStartMins
58+
[sr-en] Maximum delay in minutes after which the scheduled reboot will not take place
59+
[sr-de] Maximale Verzögerung in Minuten, nach der der geplante Neustart nicht mehr durchgeführt wird
60+
61+
.Parameter Frequency
62+
[sr-en] Reboot schedules with the specified frequency
63+
[sr-de] Neustartzeitpläne mit der angegebenen Häufigkeit
64+
65+
.Parameter FrequencyFactor
66+
[sr-en] Reboot schedules with the specified frequency factor
67+
[sr-de] Neustartzeitpläne mit dem angegebenen Faktor
68+
69+
.Parameter IgnoreMaintenanceMode
70+
[sr-en] Reboot machines in maintenance mode
71+
[sr-de] Neustartzeitpläne mit Neustart im Wartungsmodus
72+
73+
.Parameter RebootDuration
74+
[sr-en] Reboot schedules with the specified duration
75+
[sr-de] Neustartzeitpläne mit der angegebenen Dauer
76+
77+
.Parameter RestrictToTag
78+
[sr-en] Reboot schedules with the specified tag
79+
[sr-de] Neustartzeitpläne mit dem angegebenen Tag
80+
81+
.Parameter UseNaturalReboot
82+
[sr-en] Reboot schedules with the specified value
83+
[sr-de] Neustartzeitpläne mit dem angegebenen Wert
84+
85+
.Parameter WarningRepeatInterval
86+
[sr-en] Reboot schedules with the specified warning repeat interval
87+
[sr-de] Neustartzeitpläne mit dem Warnung Wiederholungsintervall
88+
89+
.Parameter WeekInMonth
90+
[sr-en] Reboot schedules with the specified week in a month
91+
[sr-de] Neustartzeitpläne die für diesen Woche konfiguriert sind
92+
93+
.Parameter Properties
94+
[sr-en] List of properties to expand. Use * for all properties
95+
[sr-de] Liste der zu anzuzeigenden Eigenschaften. Verwenden Sie * für alle Eigenschaften
96+
#>
97+
98+
param(
99+
[string]$SiteServer,
100+
[string]$Uid,
101+
[string]$RebootScheduleName,
102+
[bool]$Active,
103+
[bool]$Enabled,
104+
[ValidateSet('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')]
105+
[string[]]$Day,
106+
[ValidateSet('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday')]
107+
[string]$DayInMonth,
108+
[int]$DesktopGroupUid,
109+
[ValidateSet('Weekly','Daily','Monthly')]
110+
[string]$Frequency,
111+
[int]$FrequencyFactor,
112+
[bool]$IgnoreMaintenanceMode,
113+
[int]$MaxOvertimeStartMins,
114+
[int]$RebootDuration,
115+
[string]$RestrictToTag,
116+
[bool]$UseNaturalReboot,
117+
[int]$WarningRepeatInterval,
118+
[ValidateSet('First','Second','Third','Fourth','Last')]
119+
[string]$WeekInMonth,
120+
[ValidateSet('*','Name','Description','Active','Enabled','Day','DayInMonth','DesktopGroupName','DesktopGroupUid',
121+
'Frequency','FrequencyFactor','IgnoreMaintenanceMode','MaxOvertimeStartMins','RebootDuration','RestrictToTag',
122+
'StartDate','StartTime','Uid','UseNaturalReboot','WarningDuration','WarningMessage','WarningRepeatInterval','WarningTitle','WeekInMonth')]
123+
[string[]]$Properties = @('Name','Description','Active','Enabled','DesktopGroupName','Frequency','IgnoreMaintenanceMode','Uid')
124+
)
125+
126+
try{
127+
StartCitrixSessionAdv -ServerName ([ref]$SiteServer)
128+
if($Properties -contains '*'){
129+
$Properties = @('*')
130+
}
131+
132+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
133+
'AdminAddress' = $SiteServer
134+
'Property' = $Properties
135+
}
136+
137+
if([System.String]::IsNullOrWhiteSpace($Uid) -eq $false){
138+
$cmdArgs.Add('Uid',$Uid)
139+
}
140+
if($PSBoundParameters.ContainsKey('RebootScheduleName') -eq $true){
141+
$cmdArgs.Add('RebootScheduleName',$RebootScheduleName)
142+
}
143+
if($PSBoundParameters.ContainsKey('Active') -eq $true){
144+
$cmdArgs.Add('Active',$Active)
145+
}
146+
if($PSBoundParameters.ContainsKey('Enabled') -eq $true){
147+
$cmdArgs.Add('Enabled',$Enabled)
148+
}
149+
if($PSBoundParameters.ContainsKey('DesktopGroupUid') -eq $true){
150+
$cmdArgs.Add('DesktopGroupUid',$DesktopGroupUid)
151+
}
152+
if($PSBoundParameters.ContainsKey('Day') -eq $true){
153+
$cmdArgs.Add('Day',($Day -join ','))
154+
}
155+
if($PSBoundParameters.ContainsKey('DayInMonth') -eq $true){
156+
$cmdArgs.Add('DayInMonth',$DayInMonth)
157+
}
158+
if($FrequencyFactor -gt 0){
159+
$cmdArgs.Add('FrequencyFactor',$FrequencyFactor)
160+
}
161+
if($MaxOvertimeStartMins -gt 0){
162+
$cmdArgs.Add('MaxOvertimeStartMins',$MaxOvertimeStartMins)
163+
}
164+
if($RebootDuration -gt 0){
165+
$cmdArgs.Add('RebootDuration',$RebootDuration)
166+
}
167+
if($WarningRepeatInterval -gt 0){
168+
$cmdArgs.Add('WarningRepeatInterval',$WarningRepeatInterval)
169+
}
170+
if($PSBoundParameters.ContainsKey('Frequency') -eq $true){
171+
$cmdArgs.Add('Frequency',$Frequency)
172+
}
173+
if($PSBoundParameters.ContainsKey('IgnoreMaintenanceMode') -eq $true){
174+
$cmdArgs.Add('IgnoreMaintenanceMode',$IgnoreMaintenanceMode)
175+
}
176+
if($PSBoundParameters.ContainsKey('UseNaturalReboot') -eq $true){
177+
$cmdArgs.Add('UseNaturalReboot',$UseNaturalReboot)
178+
}
179+
if($PSBoundParameters.ContainsKey('RestrictToTag') -eq $true){
180+
$cmdArgs.Add('RestrictToTag',$RestrictToTag)
181+
}
182+
if($PSBoundParameters.ContainsKey('WeekInMonth') -eq $true){
183+
$cmdArgs.Add('WeekInMonth',$WeekInMonth)
184+
}
185+
186+
$ret = Get-BrokerRebootScheduleV2 @cmdArgs | Select-Object $Properties | Sort-Object Name
187+
188+
if($SRXEnv) {
189+
$SRXEnv.ResultMessage = $ret
190+
}
191+
else{
192+
Write-Output $ret
193+
}
194+
}
195+
catch{
196+
throw
197+
}
198+
finally{
199+
CloseCitrixSession
200+
}

0 commit comments

Comments
 (0)