@@ -31,11 +31,6 @@ function Set-AzDoProjectSetting {
3131 [string ]
3232 $CollectionUri ,
3333
34- # PAT to get access to Azure DevOps.
35- [Parameter ()]
36- [string ]
37- $PAT ,
38-
3934 # Name of the project
4035 [Parameter (Mandatory , ValueFromPipeline , ValueFromPipelineByPropertyName )]
4136 [string ]
@@ -136,22 +131,14 @@ function Set-AzDoProjectSetting {
136131 [switch ]
137132 $StatusBadgesArePrivate
138133 )
139- Begin {
140- begin {
141- if (-not ($script :header )) {
142-
143- try {
144- New-ADOAuthHeader - PAT $PAT - ErrorAction Stop
145- } catch {
146- $PSCmdlet.ThrowTerminatingError ($_ )
147- }
148- }
149- }
150134
151- $Projects = (Get-AzDoProject - CollectionUri = $CollectionUri - ProjectName $ProjectName - PAT $PAT | Where-Object ProjectName -EQ $ProjectName ).Projectid
152- }
153- Process {
154- $Body = @ {
135+ begin {
136+ Write-Verbose " Starting function: Set-AzDOProjectSetting"
137+ }
138+
139+ process {
140+
141+ $body = @ {
155142 buildsEnabledForForks = [bool ]$BuildsEnabledForForks
156143 disableClassicBuildPipelineCreation = [bool ]$DisableClassicBuildPipelineCreation
157144 disableClassicPipelineCreation = [bool ]$DisableClassicPipelineCreation
@@ -174,14 +161,15 @@ function Set-AzDoProjectSetting {
174161 }
175162
176163 $params = @ {
177- uri = " $CollectionUri /$ProjectId /_apis/build/generalsettings?api-version=7.2-preview.1"
164+ uri = " $CollectionUri /$ProjectName /_apis/build/generalsettings?api-version=7.2-preview.1"
178165 Method = ' PATCH'
179166 Headers = $script :header
180- body = $Body
167+ body = $body
181168 ContentType = ' application/json'
182169 }
183170
184171 if ($PSCmdlet.ShouldProcess ($CollectionUri , " Set provided settings at the project named: $ ( $PSStyle.Bold ) $Projectname $ ( $PSStyle.Reset ) " )) {
172+
185173 $response = Invoke-RestMethod @params
186174
187175 [PSCustomObject ]@ {
@@ -207,7 +195,7 @@ function Set-AzDoProjectSetting {
207195 StatusBadgesArePrivate = $response.statusBadgesArePrivate
208196 }
209197 } else {
210- $body
198+ Write-Verbose " Calling Invoke-AzDoRestMethod with $ ( $params | ConvertTo-Json - Depth 10 ) "
211199 }
212200 }
213201}
0 commit comments