Private/MaintenanceState/Test-MaintenanceAllowed.ps1
function Test-MaintenanceAllowed { #Requires -Version 3.0 [CmdletBinding()] [OutputType([System.Boolean])] Param ( [Parameter(Mandatory)] [string]$ComputerName ) $ErrorActionPreference = 'Stop' Write-Debug -Message ('ENTER {0}' -f $MyInvocation.MyCommand.Name) try { Write-Debug -Message ('ENTER TRY {0}' -f $MyInvocation.MyCommand.Name) Write-Debug -Message ('$ComputerName = ''{0}''' -f $ComputerName) Write-Debug -Message ('$ComputerMaintenanceConfiguration = Get-ComputerMaintenanceConfiguration -ComputerName {0}' -f $ComputerName) $ComputerMaintenanceConfiguration = Get-ComputerMaintenanceConfiguration -ComputerName $ComputerName Write-Debug -Message ('$ComputerMaintenanceConfiguration: ''{0}''' -f $ComputerMaintenanceConfiguration) Write-Debug -Message ('$ComputerMaintenanceConfiguration.Disabled: ''{0}''' -f $ComputerMaintenanceConfiguration.Disabled) Write-Debug -Message 'if ($ComputerMaintenanceConfiguration.Disabled)' if ($ComputerMaintenanceConfiguration.Disabled) { Write-Debug -Message '$false' $false } else { Write-Debug -Message '$true' $true } Write-Debug -Message ('EXIT TRY {0}' -f $MyInvocation.MyCommand.Name) } catch { Write-Debug -Message ('ENTER CATCH {0}' -f $MyInvocation.MyCommand.Name) Write-Debug -Message ('{0}: $PSCmdlet.ThrowTerminatingError($_)' -f $MyInvocation.MyCommand.Name) $PSCmdlet.ThrowTerminatingError($_) Write-Debug -Message ('EXIT CATCH {0}' -f $MyInvocation.MyCommand.Name) } Write-Debug -Message ('EXIT {0}' -f $MyInvocation.MyCommand.Name) } |