I have 2 machines (workstation and server) that I am trying to run the sample code below on, and get a different result on each machine. Both machines have a very close PS version (but not exact). I'm stuck at where to look next for this issue.
Sample code:
$xml = "<contactUser><name>Some name</name></contactUser>"
Invoke-RestMethod -Credential (Get-Credential) -Method "Post" -Uri "https://app/api/blah" -Body $xml -ContentType "application/xml"
On our server (Win 2012 R2), I get the following error message. The interesting thing is that the request seems to execute without any issues. I can check the app afterwards and verify that it worked, but I still get the error message:
Invoke-RestMethod : Value cannot be null.
Parameter name: name
On my workstation (Win10 Enterprise LTSB ver 1607), the same code runs fine.
Here are the values from $PSVersionTable:
Server (not working):
Name Value
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Workstation (working):
Name Value
PSVersion 5.1.14393.3471
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3471
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I tried to search out the specific PS version to install on the server, but couldn't find anything. I also thought that the .NET Framework versions on each machine might be different and could be the source of the issue, but they both appear to have the same version installed.
I also tried installing PowerShell 7 on the server, and the code ran without issues, but I ran into other issues when trying to load the module we've developed to work with the API for this app, and I'm not sure how easy it would be to update our code.
So that's where I am now - unsure of what I can look at next to find the difference between my workstation and the server, to hopefully fix the problem.
Any suggestions would be a huge help...