-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforcesync.ps1
More file actions
25 lines (21 loc) · 763 Bytes
/
Copy pathforcesync.ps1
File metadata and controls
25 lines (21 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$EnvironmentName = 'EnvironmentID'
$groupName='display name of the group'
#Get environment
$Environment = Get-AdminPowerAppEnvironment -EnvironmentName $EnvironmentName
if($Environment)
{
#AzureAD part. Connect to azure and retrieve enabled users
Connect-AzureAD
#Using SecurityGroups
$Group = Get-AzureADGroup | Where { $_.DisplayName -eq $groupName }
$users = Get-AzureADGroupMember -ObjectId $group.ObjectId
#Querying directly the AzureAD
$users = Get-AzureADUser -all $true | where {$_.accountenabled -eq $true}
$users
#iterating through the array of users
foreach ($user in $users)
{
#Force sync on each user
Add-AdminPowerAppsSyncUser -EnvironmentName $Environment.EnvironmentName -PrincipalObjectId $user.ObjectId
}
}