The script is indeed good. What you appear to be lacking is good error handling. The "NaN" that you're receiving means "Not a Number". That means whatever is being returned is a string and not an integer. Since your script appears to work without issue on my machine, the problem is most likely with your WinRM configuration. I'll assume you are trying to execute this script against a remote host? If that's the case you need to ensure that WinRM is properly configured on both the Orion server itself, as well as the remote host where you wish the script to run.