crlogic

Get-AoCInput

Dec 6th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # Set-Secret AoCToken -Secret (Get-Credential)
  2. # https://devblogs.microsoft.com/powershell/secretmanagement-and-secretstore-are-generally-available/
  3. $date = Get-Date
  4. $day = $date.day
  5. $year = $date.year
  6. $url = "https://adventofcode.com/$year/day/$day/input"
  7. $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
  8. $aocToken = Get-Secret AoCToken
  9. $session.Cookies.Add((New-Object System.Net.Cookie("session", $aocToken.getNetworkCredential().Password, "/", ".adventofcode.com")))
  10. $puzzleInput = Invoke-RestMethod -Uri $url -WebSession $session
  11.  
Advertisement
Add Comment
Please, Sign In to add comment