Public/Disable-MaintenanceMode.ps1
Function Disable-MaintenanceMode { <# .Synopsis Disable MaintenanceMode on server .Description Disable MaintenanceMode on Citrix XenApp servers .Parameter ServerName The servername .Example Disable-MaintenanceMode -ServerName XA01.DOMAIN.COM Disables 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 take out of maintenance (FQDN!)' )] [ValidateScript( { Test-FQDN -FQDN $_ })] [Alias('ComputerName', 'CN')] [string[]]$ServerName ) Begin { } Process { Foreach ($Server in $ServerName) { Try { If ($PSCmdlet.ShouldProcess("Disable-MaintenanceMode", "Get server name")) { $name = Get-BrokerSharedDesktop -DNSName $ServerName -ErrorAction Stop } If ($PSCmdlet.ShouldProcess("Disable-MaintenanceMode", "Disable maintenance for server: $name")) { Set-BrokerSharedDesktop $name -InMaintenanceMode $false -ErrorAction Stop } } Catch { Write-Warning $_.Exception.Message } } } End { } } Set-Alias -Name Stop-Maintenance -Value Disable-MaintenanceMode -Description "Disable Maintenance Mode" -Option ReadOnly -PassThru -ErrorAction SilentlyContinue |