Skip to content

Instantly share code, notes, and snippets.

@EntityReborn
Last active August 12, 2016 05:49
Show Gist options
  • Save EntityReborn/09d715a0a1aacc2ea9312112268f75bd to your computer and use it in GitHub Desktop.
Save EntityReborn/09d715a0a1aacc2ea9312112268f75bd to your computer and use it in GitHub Desktop.
. .\Config.ps1 # $username = 'blah'\n$password = 'blah'
Add-Type -Path .\WebDriver.dll
$msdn = 'https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1470967868&rver=6.7.6640.0&wp=mcmbi&wlcxt=msdn%24msdn%24msdn&wreply=https%3a%2f%2fmsdn.microsoft.com%2fen-us%2fsubscriptions%2fdownloads%2f&lc=1033&id=254354&mkt=en-us'
$driverService = [OpenQA.Selenium.PhantomJS.PhantomJSDriverService]::CreateDefaultService()
$driverService.HideCommandPromptWindow = true;
$selenium = [OpenQA.Selenium.PhantomJS.PhantomJSDriver]::new($driverService)
$selenium.Navigate().GoToUrl($msdn)
Start-Sleep -Seconds 1 # Let things settle down. Sometimes logging in will happen too fast otherwise.
$user = $selenium.FindElementByCssSelector('input[type="email"]')
$pass = $selenium.FindElementByCssSelector('input[type="password"]')
$btn = $selenium.FindElementByCssSelector('input[type="submit"]')
$user.SendKeys($username)
$pass.SendKeys($password)
$btn.Click()
$cookies = $selenium.Manage().Cookies.AllCookies
$selenium.Quit()
$Jar = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$cookies | % { $Jar.Cookies.Add( [Net.Cookie]($_ | Select-Object Name, Value, Domain) ) }
$response = Invoke-WebRequest -Uri 'https://msdn.microsoft.com/en-us/subscriptions/securejson/getallexportkeys?brand=msdn' -WebSession $Jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment