The following error is thrown on attempt to execute the commands Invoke-WebRequest from KB126807:
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, o r if a path was included, verify that the path is correct and try again. At line:1 char:34 + $authResponse = Invoke-RestMethod <<<< -Method POST -Uri "https://login.microsoftonline.com/$tenantId/oauth2/token" -ContentType "application/x-ww w-form-urlencoded" -body $authParams + CategoryInfo : ObjectNotFound: (Invoke-RestMethod:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Invoke-RestMethod cmdlet was introduced in Powershell 3.0 which is missing or not installed on Office 365 endpoint server.
Make sure that Powershell 3.0 is installed on the endpoint server.