Update a policy configuration for an Azure DevOps project.
Set-AdoPolicyConfiguration [[-CollectionUri] <string>] [[-ProjectName] <string>] [-Id] <int> [-Configuration] <object> [[-Version] <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
This cmdlet has the following aliases,
- N/A
This cmdlet updates an existing policy configuration for an Azure DevOps project. The configuration must be provided as a PSCustomObject or hashtable containing all required policy settings.
$params = @{
CollectionUri = 'https://dev.azure.com/my-org'
ProjectName = 'my-project-1'
}
$config = [PSCustomObject]@{
isEnabled = $true
isBlocking = $true
type = @{
id = 'fa4e907d-c16b-4a4c-9dfa-4906e5d171dd'
}
settings = @{
minimumApproverCount = 2
creatorVoteCounts = $true
allowDownvotes = $false
resetOnSourcePush = $false
requireVoteOnLastIteration = $false
resetRejectionsOnSourcePush = $false
blockLastPusherVote = $false
requireVoteOnEachIteration = $false
scope = @(
@{
repositoryId = $null
refName = $null
matchKind = 'DefaultBranch'
}
)
}
}
Set-AdoPolicyConfiguration @params -Id 1 -Configuration $configUpdates the policy configuration with ID 1 in the 'my-project-1' project.
$params = @{
CollectionUri = 'https://dev.azure.com/my-org'
ProjectName = 'my-project-1'
}
$config = [PSCustomObject]@{
isEnabled = $false
isBlocking = $true
type = @{ id = 'fa4e907d-c16b-4a4c-9dfa-4906e5d171dd' }
settings = @{ minimumApproverCount = 1 }
}
1, 2, 3 | Set-AdoPolicyConfiguration @params -Configuration $configUpdates multiple policy configurations using pipeline input. The process block executes once per ID.
The collection URI of the Azure DevOps collection/organization, e.g., https://dev.azure.com/my-org. Defaults to $env:DefaultAdoCollectionUri.
Type: System.String
DefaultValue: $env:DefaultAdoCollectionUri
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The ID or name of the project. Defaults to $env:DefaultAdoProject.
Type: System.String
DefaultValue: $env:DefaultAdoProject
SupportsWildcards: false
Aliases:
- ProjectId
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The ID of the configuration to update.
Type: System.Int32
DefaultValue:
SupportsWildcards: false
Aliases:
- ConfigurationId
ParameterSets:
- Name: (All)
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The configuration object for the policy. Can be a PSCustomObject or hashtable containing all required policy settings.
Type: System.Object
DefaultValue:
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The API version to use for the request.
Type: System.String
DefaultValue: 7.1
SupportsWildcards: false
Aliases:
- ApiVersion
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues:
- 7.1
- 7.2-preview.1
HelpMessage: ''This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- N/A
-
Requires authentication to Azure DevOps. Use
Set-AdoDefaultto configure default organization and project values. -
The cmdlet automatically retrieves authentication through
Invoke-AdoRestMethodwhich callsNew-AdoAuthHeader. -
If a policy configuration with the specified ID does not exist, a warning is displayed and the cmdlet continues execution.