I'd like to access a SharePoint web service behind a TMG server. The TMG server requires form based authentication and I'm not able to get past that. This is what I've tried:
$user='domain\user'
$pwd=Read-Host -AsSecureString
$loginurl="https://domain.com/CookieAuth.dll?Logon"
$body = @{
username=$user
password=$pwd
}
$response=Invoke-RestMethod -Uri $loginurl -Method Post -Body $body
$response
I then plan to use the cookie to access the web service:
$Url = "https://domain.com/Sites/Test/_api/web/lists/GetByTitle('TestList')/items"
$header = @{
'token' = 'TokenValueFromPreviousResponse'
}
Invoke-RestMethod -Method Post -Uri $Url -Header $header | ft
I can't get the first part working. I also had a look at this blog post but it doesn't give much details: http://sharepointificate.blogspot.com/2011/09/accessing-sharepoint-webservices-behind.html
Any help appreciated.