Functions/PlatformManagement/Test-RemotePowerShell.ps1
function Test-RemotePowershell { param( [Parameter(Mandatory=$true)] [string] $computerName ) try { # Try a simple command with timeout and retrieve only one process. $sessionOption = New-PSSessionOption -OperationTimeout 5000 # Timeout in milliseconds. Invoke-Command -ComputerName $computerName -SessionOption $sessionOption { Get-Process | Select-Object -First 1 } -ErrorAction Stop | Out-Null # If the command did not throw an error, return true. return $true } catch { # If the command threw an error, return false. return $false } } Export-ModuleMember -Function Test-RemotePowershell |