Advertisement
Shell_Casing

Untitled

Jul 23rd, 2019
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. function Create-BasicAuthHeader {
  4.   Param(
  5.     [Parameter(Mandatory=$true)]
  6.     [string]$Name,
  7.     [Parameter(Mandatory=$true)]
  8.     [string]$PAT
  9. )
  10.  
  11.   $Auth = '{0}:{1}' -f $Name, $PAT
  12.   $Auth = [System.Text.Encoding]::UTF8.GetBytes($Auth)
  13.   $Auth = [System.Convert]::ToBase64String($Auth)
  14.   $Header = @{Authorization=("Basic {0}" -f $Auth)}
  15.   $Header
  16. }
  17.  
  18. Invoke-WebRequest -Uri 'https://dev.azure.com/<organisation name>/_apis/projects' -Headers (Create-BasicAuthHeader 'Azure TOKEN_NAME' '<personal access token>') -Method Get
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement