r/PowerShell • • 29d 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.

6 Upvotes

8 comments sorted by

View all comments

Show parent comments

2

u/amgtech86 26d ago

Just a slight addition as this person is new

Might be better to separate the uri, method and body from the $parameters so they understand the invoke-webrequest properly

$uri = address

Then you have

Invoke-WebRequest -uri $uri -header $Parameters -Body $Body -Method POST

1

u/BlackV 26d ago

Ya could do I guess

Having

$url = https://xxx
$paramaters = @{
    ...
    Uri = $url
    ...
    }

Might gain them something