Skip to main content

Add-VSTeamGitRepositoryPermission

SYNOPSIS

Add permissions to a git repository, all repositories in a project, or a specific branch

SYNTAX

ByProjectAndUser (Default)

Add-VSTeamGitRepositoryPermission -Project <Project> -User <User> [-Allow <GitRepositoryPermissions>]
[-Deny <GitRepositoryPermissions>] [-OverwriteMask] [<CommonParameters>]

ByRepositoryIdAndDescriptor

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryId <Guid> [-BranchName <String>]
-Descriptor <String> [-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask]
[<CommonParameters>]

ByRepositoryIdAndUser

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryId <Guid> [-BranchName <String>] -User <User>
[-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask] [<CommonParameters>]

ByRepositoryIdAndGroup

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryId <Guid> [-BranchName <String>] -Group <Group>
[-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask] [<CommonParameters>]

ByRepositoryNameAndDescriptor

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryName <String> [-BranchName <String>]
-Descriptor <String> [-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask]
[<CommonParameters>]

ByRepositoryNameAndUser

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryName <String> [-BranchName <String>]
-User <User> [-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask]
[<CommonParameters>]

ByRepositoryNameAndGroup

Add-VSTeamGitRepositoryPermission -Project <Project> -RepositoryName <String> [-BranchName <String>]
-Group <Group> [-Allow <GitRepositoryPermissions>] [-Deny <GitRepositoryPermissions>] [-OverwriteMask]
[<CommonParameters>]

ByProjectAndDescriptor

Add-VSTeamGitRepositoryPermission -Project <Project> -Descriptor <String> [-Allow <GitRepositoryPermissions>]
[-Deny <GitRepositoryPermissions>] [-OverwriteMask] [<CommonParameters>]

ByProjectAndGroup

Add-VSTeamGitRepositoryPermission -Project <Project> -Group <Group> [-Allow <GitRepositoryPermissions>]
[-Deny <GitRepositoryPermissions>] [-OverwriteMask] [<CommonParameters>]

DESCRIPTION

Add permissions to a git repository, all repositories in a project, or a specific branch

EXAMPLES

Example 1

$descriptorUser = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMA"
$descriptorGroup = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMQ"
Add-VSTeamGitRepositoryPermission -RepositoryId "1a2b3c4d" -RepositoryName "MyRepo" -BranchName "main" -Descriptor $descriptorUser -User $descriptorUser -Group $descriptorGroup -Allow "Read,Contribute" -Deny "Delete" -ProjectName "WebAppProject"

This command adds read and contribute permissions to the "main" branch of the "MyRepo" repository for the specified user and group while denying the delete permission. The user and group are specified using their respective descriptors.

Example 2

$descriptorUser = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMA"
Add-VSTeamGitRepositoryPermission -RepositoryId "2b3c4d5e" -RepositoryName "AnotherRepo" -BranchName "dev" -Descriptor $descriptorUser -User $descriptorUser -Allow "Read" -ProjectName "BackendServices"

Here, read permission is granted to the "dev" branch of the "AnotherRepo" repository for the specified user using the user descriptor.

Example 3

$descriptorGroup = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMQ"
Add-VSTeamGitRepositoryPermission -RepositoryId "3c4d5e6f" -RepositoryName "ThirdRepo" -BranchName "feature" -Descriptor $descriptorGroup -Group $descriptorGroup -Allow "Read,Contribute,Manage" -ProjectName "DataAnalytics"

In this example, read, contribute, and manage permissions are granted to the "feature" branch of the "ThirdRepo" repository for the specified group using the group descriptor.

Example 4

$descriptorUser = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMA"
Add-VSTeamGitRepositoryPermission -RepositoryId "4d5e6f7g" -RepositoryName "FourthRepo" -BranchName "hotfix" -Descriptor $descriptorUser -User $descriptorUser -Allow "Read" -Deny "Contribute,Delete" -ProjectName "MobileApp"

This command grants read permission and denies contribute and delete permissions to the "hotfix" branch of the "FourthRepo" repository for the specified user using the user descriptor.

Example 5

$descriptorGroup = "vssgp.Uy0xLTktMTU1MTM3NDI0NS0xMzM4Mzc4Njg5LTE5MzM0NTM5NjYtMzQ3NzU4NjI4OS0yNTA2ODc2NTA5LTAuMQ"
Add-VSTeamGitRepositoryPermission -RepositoryId "5e6f7g8h" -RepositoryName "FifthRepo" -BranchName "release" -Descriptor $descriptorGroup -Group $descriptorGroup -Allow "Read,Contribute" -ProjectName "FrontendUI"

This example grants read and contribute permissions to the "release" branch of the "FifthRepo" repository for the specified group using the group descriptor.

PARAMETERS

-RepositoryId

@{Text=}

Type: Guid
Parameter Sets: ByRepositoryIdAndDescriptor, ByRepositoryIdAndUser, ByRepositoryIdAndGroup
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-RepositoryName

@{Text=}

Type: String
Parameter Sets: ByRepositoryNameAndDescriptor, ByRepositoryNameAndUser, ByRepositoryNameAndGroup
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BranchName

@{Text=}

Type: String
Parameter Sets: ByRepositoryIdAndDescriptor, ByRepositoryIdAndUser, ByRepositoryIdAndGroup, ByRepositoryNameAndDescriptor, ByRepositoryNameAndUser, ByRepositoryNameAndGroup
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Descriptor

@{Text=}

Type: String
Parameter Sets: ByRepositoryIdAndDescriptor, ByRepositoryNameAndDescriptor, ByProjectAndDescriptor
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-User

@{Text=}

Type: User
Parameter Sets: ByProjectAndUser, ByRepositoryIdAndUser, ByRepositoryNameAndUser
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Group

@{Text=}

Type: Group
Parameter Sets: ByRepositoryIdAndGroup, ByRepositoryNameAndGroup, ByProjectAndGroup
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Allow

@{Text=}

Type: GitRepositoryPermissions
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Deny

@{Text=}

Type: GitRepositoryPermissions
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-OverwriteMask

Switch to overwrite the mask values rather than merge them.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Project

{{ Fill Project Description }}

Type: Project
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Object

NOTES

Prerequisites:

Set the account and version that all calls will use with Set-VSTeamAccount. Default version sets to API version 3.0 (TFS2017) if not manually set.

tips:

  • check called version of the API with Get-VSTeamAPIVersion or Get-VSTeamInfo
  • use Set-VSTeamDefaultProject to set default project for every call
  • use Set-VSTeamDefaultAPITimeout to change the default timeout of 60 seconds for all calls.
  • use Profiles to load an account and the correct version