This cmdlet from client allows me to check to see if remoting with Powershell is enabled on server. In example below, results say it is:
PS C:\WINDOWS\system32> Test-WsMan xxx.104.50.xxx
wsmid : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor : Microsoft Corporation
ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0
However, I don't know how to get a true/false back from running Test-WsMan. In my automation script I want to check if remoting is enabled, and if not, stop the script and exit.
I hope my question makes sense and I hope someone is a lot smarter than me.
From MSDN
If the tested computer is running the service, the cmdlet displays the WS-Management identity schema, the protocol version, the product vendor, and the product version of the tested service.
MSDN does not explicitly state what it does when it is not running the service but I am sure you could just treat this as a truthy falsy. If nothing is returned it is not working. PowerShell is very good at evaluating expressions as booleans.
if(test-wsman $computer -ErrorAction SilentlyContinue){
# Remoting is enabled
} else {
# Something is wrong.
}
-ErrorAction SilentlyContinue
would cover any reason for failure like if the name was wrong or otherwise not contactable. It would be up to you to determine what to do if remoting is "not working".