functions/Test-CConnection.ps1
|
function Test-CConnection { [CmdletBinding()] [OutputType([bool])] param () try { if (-not $script:isConnected) { return $false } if (-not ($script:isConnected -and $script:session -and $script:Uri)) { return $false } $machines = Get-CMachine -ErrorAction Stop 2>$null return ($null -ne $machines) } catch { return $false } } |