Forum Discussion
Powershell calling a script
Hi,
How do you call a script via PowerShell? Looking to do the equivalent of this successful curl command but via PS:
curl -k -u admin -H "Content-Type: application/json" -X POST https://10.1.1.245/mgmt/tm/cli/script -d "{\"command\":\"run\",\"utilCmdArgs\":\"dtstest 10.1.10.1\"}"
Attempted to do the PowerShell call similar to the curl call but it errors out:
$body = @{ utilCmdArgs = "dtstest 10.1.10.1" command = "run" }
Invoke-RestMethod -Credential admin -Method POST -ContentType "application/json" -Body $body -Uri "https://10.1.1.245/mgmt/tm/cli/script"
ERROR:
Invoke-RestMethod : {"code":400,"message":"Found invalid JSON body in the request.","errorStack":[]}
Thanks, -Dan
Your body needs to be just like it is in your curl example. It needs to be in JSON format. i.e.
$body = '{ "command":"run", "utilCmdArgs":"dtstest 10.1.10.1" }'
- Brad_ParkerCirrus
Your body needs to be just like it is in your curl example. It needs to be in JSON format. i.e.
$body = '{ "command":"run", "utilCmdArgs":"dtstest 10.1.10.1" }'
- DanSchuster_234Historic F5 AccountThanks Brad, works perfectly now!!!!!
- Brad_Parker_139Nacreous
Your body needs to be just like it is in your curl example. It needs to be in JSON format. i.e.
$body = '{ "command":"run", "utilCmdArgs":"dtstest 10.1.10.1" }'
- DanSchuster_234Historic F5 AccountThanks Brad, works perfectly now!!!!!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com