function Test-ComputerIsAvailable { <# .SYNOPSIS Test that a given computer is on and able to be connected to .PARAMETER ComputerName [string] Computer to connect to. Assumes .fh.local domain .PARAMETER NotFHLocal [switch] Disable check to see if it is a .fh.local computer name #> [CmdletBinding()] [OutputType([bool])] param ( [string]$ComputerName, [switch]$NotFHLocal ) try { if (!$NotFHLocal -and !$ComputerName.EndsWith('.fh.local')) { $ComputerName = "$ComputerName.fh.local" } $session = New-PSSession -ComputerName $ComputerName Remove-PSSession $session return $true } catch { return $false } }