본문 바로가기

파워쉘

[파워쉘] InternetExplorer.Application에서 headers 세팅

InternetExplorer.Application의 Navigate2 메소드 사용 시 동시에 여러가지 헤더를 세팅해야 할 경우가 있다.


1. user-agent를 iOS6으로 세팅

   User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25

2. post 형식으로 데이터를 넘긴다고 세팅

   Content-Type: application/x-www-form-urlencoded


이 경우 다음과 같이 스크립팅하면 해결된다.


$header = "User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"+[char]10+[char]13, "Content-Type: application/x-www-form-urlencoded"+[char]10+[char]13

$ie = New-Object -com internetexplorer.application
$ie.Navigate2('http://daum.net',0,0,0,$header)
$ie.Visible = $true