Skip to content

Instantly share code, notes, and snippets.

@phaniav
Created March 21, 2019 15:17
Show Gist options
  • Save phaniav/0dbf8a292fa88ec48d29c6ce0e116de0 to your computer and use it in GitHub Desktop.
Save phaniav/0dbf8a292fa88ec48d29c6ce0e116de0 to your computer and use it in GitHub Desktop.
PowerShell snippet to login to Sitecore using Invoke-WebRequest
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = 'https://sitecore-cm.domain.com/sitecore/login'
$password = 'yourpasseordhere'
$Body = @{
User = 'username'
password = $password
}
$LoginResponse = Invoke-WebRequest -Uri -Method Post -Headers @{"Content-Type" = "application/x-www-form-urlencoded"} `
-Body $Body -SessionVariable 'Session'
$Session
$LoginResponse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment