Public/Enable-MaintenanceMode.ps1
Function Enable-MaintenanceMode { <# .Synopsis Enable MaintenanceMode on server .Description Enable MaintenanceMode on Citrix XenApp servers .Parameter ServerName The servername .Example Enable-MaintenanceMode -servername XA01.DOMAIN.COM Enables MaintenanceMode on XA01.DOMAIN.COM .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding( ConfirmImpact = 'Medium', SupportsShouldProcess = $true )] [OutputType('String')] Param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = 'Server to put in maintenance (FQDN!)' )] [ValidateScript( { Test-FQDN -FQDN $_ })] [Alias('ComputerName', 'CN')] [String[]]$ServerName ) Begin { } Process { Try { If ($PSCmdlet.ShouldProcess("Enable-MaintenanceMode", "Get server name")) { $name = Get-BrokerSharedDesktop -DNSName $servername -ErrorAction Stop } If ($PSCmdlet.ShouldProcess("Enable-MaintenanceMode", "Enable maintenance for server: $name")) { Set-BrokerSharedDesktop $name -InMaintenanceMode $true -ErrorAction Stop } } Catch { Write-Warning $_.Exception.Message } } End { } } Set-Alias -Name Start-Maintenance -Value Enable-MaintenanceMode -Description "Enable Maintenance Mode" -Option ReadOnly -PassThru -ErrorAction SilentlyContinue |