-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathset-readonly.ps1
More file actions
25 lines (22 loc) · 1.12 KB
/
set-readonly.ps1
File metadata and controls
25 lines (22 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Move all Contributors to Readers
#
# Members of groups such as Project Administrator or Build Administrator groups are not affected
$groups = Get-ADOGroups `
-OrgName $SourceOrgName `
-ProjectName $SourceProjectName `
-PersonalAccessToken $SourcePAT
$contributors = $groups | Where-Object { $_.Name -eq "Contributors" }
$readers = $groups | Where-Object { $_.Name -eq "Readers" }
write-host "Adding all Contributor group user members to Readers ..."
foreach ($u in $contributors.UserMembers) {
az devops security group membership add --group-id $readers.Descriptor --member-id $u.PrincipalName --detect $false
}
foreach ($g in $contributors.GroupMembers) {
az devops security group membership add --group-id $readers.Descriptor --member-id $g.PrincipalName --detect $false
}
foreach ($g in $contributors.GroupMembers) {
az devops security group membership remove --group-id $contributors.Descriptor --member-id $g.PrincipalName --detect $false
}
foreach ($u in $contributors.UserMembers) {
az devops security group membership remove --group-id $contributors.Descriptor --member-id $u.PrincipalName --detect $false --yes
}