I get an error message when I use the 'FORM option with Invoke-WebRequest powershell utility. When I use help on the Invoke-WebRequest, I don't see the -FORM option listed. There is a Microsoft help document that shows an Example 6 with the -FORM option.
QUESTION - Is there something additional I need that supports the -FORM option for the PowerShell
Invoke-WebRequest utility?
COMMENT - The PowerShell Invoke-WebRequest utility works fine for downloading a file.
Using PS version 5.1 on Windows 10.
Here's the script and error message.
$Uri = 'http://xxxxx.xxx.xxxx.xxx:8080/upload/upload.php'
$Form = @{
file = Get-Item -Path 'C:\temp\xxxxxxx.pdf'
nmbr = 'xxxxxxx'
}
Invoke-WebRequest -Uri $Uri -Method Post -Form $Form
------------------ ERROR MESSAGE -----------------------
Invoke-WebRequest : A parameter cannot be found that matches parameter name 'Form'.
At line:6 char:42
+ Invoke-WebRequest -Uri $Uri -Method Post -Form $Form
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId :
NamedParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand