Unable to call New-WebServiceProxy in New-PSUEndpoint

New-WebServiceProxy generates the following error in the endpoint logs:

[Error] [Api-4] The term 'New-WebServiceProxy' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Here is the code that produces the error:

New-PSUEndpoint -Url "/adcomputer" -Method @('GET','POST') -Endpoint {
  New-WebServiceProxy -Uri 'https://vault/AimWebService/v1.1/AIM.asmx' -UseDefaultCredential

I see that the Micosoft.PowerShell.Management module is listed in Platform\Modules, so not really sure what the error is. I am not hosting PSU in IIS (I am using Kestrel, and PSU is running as a Windows service) as I saw a post indicating the New-WebServiceProxy doesn’t work when hosting in IIS.

Product: PowerShell Universal
Version: 4.2.21

@mcarpenter2840 Did you set your environment to Windows PowerShell 5.1? If not, that’s probably the issue since that cmdlet only works with Windows PowerShell 5.1. You would either need to explicitly set the environment on your endpoint or change the default environment for all of PSU.

That did the trick. Thank you.

1 Like