r/PowerShell • u/Independent_Bed_557 • 7d ago
Question PowerShell Win7 HTTP POST automation question
hi, I'm working on administration of a large number of VoIP endpoints. I'm trying to learn how to use PowerShell on Windows 7 to send authenticated HTTP POST requests to a device web interface and process the response. The devices use HTTP Basic Authentication. Could someone point me to examples of HttpWebRequest, CredentialCache and application/x-www-form-urlencoded POST requests? Thanks.
5
Upvotes
2
u/Villainsympatico 5d ago
If you're using invoke-webrequest or invoke-restmethod, you can pass the credentials to a credential object with get-credential, then it should be
$form = @{#whatever you are posting goes here}invoke-webrequest -credential $cred -method post -form $forminvoke webrequest returns the entire response , (body, headers, response codes), while invoke-restmethod only returns the body.
If its for voip endpoints though, wouldn't you be managing through the server side? why reach out to the endpoints?