Listing 1: Get-StoppedAutomaticService.ps1 # Begin Callout A Param([string]$ComputerName = ".", [string[]]$Exclude, [Management.Automation.PSCredential]$Credentials, [switch]$Synopsis) # End Callout A if($Synopsis){ #Begin Callout B $command = $MyInvocation.MyCommand.Name $s = '[[-ComputerName] ] [[-Exclude] ] [-Credential ] [-Synopsis]' Write-Output "$command $s" #End Callout B } else { # Begin Callout C if($Credentials) {$services = Get-WmiObject -Query ` "select * from Win32_Service where StartMode='auto' and State='stopped'" ` -ComputerName $ComputerName -Credential $Credentials } else {$services = Get-WmiObject -Query ` "select * from Win32_Service where StartMode='auto' and State='stopped'" ` -ComputerName $ComputerName } # End Callout C # Begin Callout D if($Exclude){ foreach($exclusion in $Exclude){$services = $services | Where-Object {!($_.Name -ilike $exclusion)} } } # End Callout D # Begin Callout E $services # End Callout E } 1