Invoke-webrequest
Jump to navigation
Jump to search
post json
$OldAdminPass="1234"
$NewAdminPass="123456"
$Ip = "192.168.0.1"
$HostURL = "https://$IP/"
$postParams = @{
page = 'Admin';
lang = 'en';
'oldpassword' = $OldAdminPass;
'setpassword' = $NewAdminPass;
}
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} #ignore ssl warning
Invoke-WebRequest -Uri $HostURL -method post -Body $postParams
post json
$postParams = @{
'method' = "login"
'user_login' = "administrator"
'password' = "ilopassword"
}
$postParams = $postParams | ConvertTo-Json
$var = Invoke-RestMethod -Method Post -Uri $jsonpage -Body $postParams -sessionvariable ws