I'm trying to use Invoke-RestMethod in a PowerShell script within an Orchestrator 2012 R2 runbook. When I run the runbook, it tells me:
The term 'Invoke-RestMethod' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
If I copy and paste the line from the activity to a PowerShell console on the runbook server, it works as expected. The documentation for Invoke-RestMethod tells me that it was introduced in .NET v3. The documentation for "Run .Net Script" says:
This activity is compatible with .NET CLR version 2.0 and later.
IIRC, .NET 3 was the next one after .NET 2, so I'm assuming this statement means it should support at least .NET 3 PowerShell cmdlets. Can anyone shed any light on why this isn't working for me?
PS: When I use the Invoke REST Service from the REST Integration Pack, it returns the data with quotes around the returned string, which means I have to put yet another activity after it to strip the quotes off, which is what I'm doing as a workaround. I'd rather have one extra line in an existing script, rather than have to add two extra activities to accomplish the same thing.