Apr 25 2021
08:01 AM
- last edited on
Mar 05 2024
01:10 PM
by
TechCommunityAP
Apr 25 2021
08:01 AM
- last edited on
Mar 05 2024
01:10 PM
by
TechCommunityAP
[string]$PATKey = "Paste PAT Key Here" ,
[string]$Organization = "Your Organization URL"
$UserGroupsObject = @()
$PATKey | az devops login --org $Organization
az devops configure --defaults organization=$Organization
$Users = az devops user list --top 10000 --org $Organization | ConvertFrom-Json
foreach ($user in $Users.members) {
$activeUserGroups = az devops security group membership list --id $user.user.principalName --org $Organization --relationship memberof | ConvertFrom-Json
[array]$groups = ($activeUserGroups | Get-Member -MemberType NoteProperty).Name
foreach ($group in $groups) {
$UserGroupsObject += New-Object -TypeName PSObject -Property @{
principalName = $user.user.principalName
displayName = $user.user.displayName
GroupName = $activeUserGroups.$group.principalName
}
}
}
$UserGroupsObject | Export-CSV -Path "C:\DevopsUsersAndAssignments.csv"
Feb 17 2022 08:16 AM
Feb 17 2022 08:32 AM