Skip to main content



How can we help you?


Druva Documentation

Troubleshooting 'Invoke-RestMethod' error while using Reporting API with a PowerShell script

Heads up!

We've transitioned to a new documentation portal to serve you better. Access the latest content by clicking here.

Problem description

The below PowerShell script helps to convert JSON data from Reporting API to a structured CSV file.

$secpasswd = ConvertTo-SecureString "4-434103d843e4f6980b26043b221c0d1377f4dab0909509686f34d4ad8332b691" -AsPlainText -Force

$Cred = New-Object System.Management.Automation.PSCredential ('', $secpasswd)

$User = Invoke-RestMethod -Method 'Get' -uri "" -Credential $Cred

$ | select-object 'email_id','total_files''shared_folders', 'size' | Export-Csv -path C:\ShareDetails.csv -NoTypeInformation

It uses Invoke-RestMethod cmdlet which sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that returns a richly structured data.

This article explains how to troubleshoot the below-mentioned error while using the aforementioned PowerShell script.


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.

At line:1 char:26

+ $User = Invoke-RestMethod <<<<  -Method 'Get' -uri "" -Credential $Cred

   + CategoryInfo          : ObjectNotFound: (Invoke-RestMethod:String) [], CommandNotFoundException

   + FullyQualifiedErrorId : CommandNotFoundException




The Invoke-RestMethod cmdlet was introduced in Windows PowerShell 3.0. The above error occurs if the PowerShell version installed on the machine is lower than 3.0.



Upgrade the PowerShell version to v3.0 or higher.

See also: Invoke-RestMethod.