Skip to main content

Add-VSTeamProjectPermission

SYNOPSIS

Add Permissions on Project Level

SYNTAX

ByProjectAndUser (Default)

Add-VSTeamProjectPermission -Project <Project> -User <User> [-Allow <ProjectPermissions>]
[-Deny <ProjectPermissions>] [-OverwriteMask] [<CommonParameters>]

ByProjectAndDescriptor

Add-VSTeamProjectPermission -Project <Project> -Descriptor <String> [-Allow <ProjectPermissions>]
[-Deny <ProjectPermissions>] [-OverwriteMask] [<CommonParameters>]

ByProjectAndGroup

Add-VSTeamProjectPermission -Project <Project> -Group <Group> [-Allow <ProjectPermissions>]
[-Deny <ProjectPermissions>] [-OverwriteMask] [<CommonParameters>]

DESCRIPTION

Add Permissions on Project Level

EXAMPLES

Example 1

$user = Get-VSTeamUser -Id "john.doe@example.com"
$group = Get-VSTeamGroup -ProjectName "WebAppProject" -GroupName "Contributors"
Add-VSTeamProjectPermission -Descriptor $user.Descriptor -User $user -Group $group -Allow "CreateWorkItems" -Deny "DeleteRepository" -ProjectName "WebAppProject"

This command grants the user "john.doe@example.com" the permission to "CreateWorkItems" and denies the permission to "DeleteRepository" within the "WebAppProject" project, specifically assigning these permissions to the "Contributors" group.

Example 2

$group = Get-VSTeamGroup -ProjectName "BackendServices" -GroupName "Readers"
Add-VSTeamProjectPermission -Descriptor $group.Descriptor -Group $group -Allow "ReadWorkItems" -Deny "EditCode" -ProjectName "BackendServices"

Here, the "Readers" group in the "BackendServices" project is given the permission to "ReadWorkItems" but is denied the permission to "EditCode".

Example 3

$user = Get-VSTeamUser -Id "alice.smith@example.org"
$group = Get-VSTeamGroup -ProjectName "DataAnalytics" -GroupName "DataScientists"
Add-VSTeamProjectPermission -Descriptor $user.Descriptor -User $user -Group $group -Allow "RunQueries" -Deny "DeleteQueries" -ProjectName "DataAnalytics"

In this example, the user "alice.smith@example.org" is granted the permission to "RunQueries" and is denied the permission to "DeleteQueries" within the "DataAnalytics" project. These permissions are associated with the "DataScientists" group.

Example 4

$group = Get-VSTeamGroup -ProjectName "MobileApp" -GroupName "Developers"
Add-VSTeamProjectPermission -Descriptor $group.Descriptor -Group $group -Allow "CommitChanges" -Deny "DeleteBranch" -ProjectName "MobileApp"

The "Developers" group in the "MobileApp" project is given the permission to "CommitChanges" but is denied the permission to "DeleteBranch".

Example 5

$user = Get-VSTeamUser -Id "robert.jones@example.net"
$group = Get-VSTeamGroup -ProjectName "FrontendUI" -GroupName "Designers"
Add-VSTeamProjectPermission -Descriptor $user.Descriptor -User $user -Group $group -Allow "EditDesigns" -Deny "DeleteDesigns" -ProjectName "FrontendUI"

This command allows the user "robert.jones@example.net" to "EditDesigns" and denies the permission to "DeleteDesigns" within the "FrontendUI" project. These permissions are linked to the "Designers" group.

PARAMETERS

-Descriptor

@{Text=}

Type: String
Parameter Sets: ByProjectAndDescriptor
Aliases:

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

-User

@{Text=}

Type: User
Parameter Sets: ByProjectAndUser
Aliases:

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

-Group

@{Text=}

Type: Group
Parameter Sets: ByProjectAndGroup
Aliases:

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

-Allow

@{Text=}

Type: ProjectPermissions
Parameter Sets: (All)
Aliases:

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

-Deny

@{Text=}

Type: ProjectPermissions
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