File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,10 +31,6 @@ function Invoke-AzDoRestMethod {
3131 [string ]
3232 $Method ,
3333
34- [Parameter ()]
35- [string ]
36- $Pat ,
37-
3834 [Parameter (ValueFromPipeline , ValueFromPipelineByPropertyName )]
3935 [PSCustomObject []]
4036 $Body
@@ -47,7 +43,7 @@ function Invoke-AzDoRestMethod {
4743 Write-Debug " method: $Method "
4844 Write-Debug " body: $ ( $body | ConvertTo-Json - Depth 10 ) "
4945
50- if (-not ( $Pat ) -and $ script :header ) {
46+ if ($ script :header.Authorization -match " Bearer " ) {
5147 $params = @ {
5248 Uri = " https://app.vssps.visualstudio.com/_apis/profile/profiles/me?api-version=6.0"
5349 Method = ' GET'
@@ -62,13 +58,13 @@ function Invoke-AzDoRestMethod {
6258 }
6359 } catch {
6460 Write-Verbose " Refreshing authentication header"
65- Clear-AzDoAuthHeader
61+ $ script :header = $null
6662 }
6763 }
6864
6965 if (-not ($script :header )) {
7066 try {
71- New-AzDoAuthHeader - PAT $Pat - ErrorAction Stop
67+ New-AzDoAuthHeader - ErrorAction Stop
7268 } catch {
7369 throw $_
7470 }
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ function New-AzDoPipeline {
6565 RepoName = $RepoName
6666 }
6767
68- Write-Debug " Calling Get-AzDoRepo with"
69- $RepoId = (Get-AzDoRepo @getAzDoRepoSplat ).RepoId
68+ Write-Debug " Calling Get-AzDoRepo with $ ( $getAzDoRepoSplat | ConvertTo-Json - Depth 10 ) "
69+ $RepoId = (Get-AzDoRepo @getAzDoRepoSplat - ErrorAction Stop ).RepoId
7070
7171 $body = @ {
7272 name = $PipelineName
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ function Set-AzDoPAT {
2+ <#
3+ . SYNOPSIS
4+ This script sets the header variable with a PAT.
5+ . DESCRIPTION
6+ This script sets the header variable with a PAT.
7+ . NOTES
8+ This function can be used to use a PAT for authentication instead of an Azure PowerShell access token.
9+ . EXAMPLE
10+ Set-AzDoPAT -Pat '***'
11+
12+ This example sets the header variable used for authentication with a PAT.
13+ #>
14+ [CmdletBinding (SupportsShouldProcess )]
15+ param (
16+ # PAT used for authentication
17+ [Parameter (Mandatory , ValueFromPipelineByPropertyName , ValueFromPipeline )]
18+ [string ]
19+ $Pat
20+ )
21+
22+ process {
23+ if ($PSCmdlet.ShouldProcess ()) {
24+ New-AzDoAuthHeader - Pat $Pat
25+ } else {
26+ Write-Verbose " Calling New-AzDoAuthHeader with pat"
27+ }
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments