Link to home
Start Free TrialLog in
Avatar of Sam Jacobs
Sam JacobsFlag for United States of America

asked on

Trying to Pass Custom Headers to WebsIte Via PowerShell

I am trying to navigate to a website via PowerShell and pass custom header information with the following:
$ie = new-object -comobject 'internetexplorer.Application'
$ie.Visible = $True
$headers =  @{"x-custom-1"="custom Value 1"}
$headers += @{"x-custom-2"="custom Value 2"}
$ie.Navigate("http://www.xhaus.com/headers",$Null,"_self",$Null,$headers)

Open in new window

However, the headers don't seem to be making  it to the site.
Any assistance is greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sam Jacobs

ASKER

oBdA,

Thank you very much!
I had Googled quite a bit and found that Invoke-WebRequest took a hashtable as input to its Header parameter.
I (erroneously) thought it would be the same for the COM object.
Doesn't the code above stick a CRLF at the end of all headers instead of after each one?

Thanks!
Sam
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As always, thanks for your help - for me as well as the entire PowerShell community!