Forum Discussion
Removing Manager for all disabled users
- Oct 04, 2022
raindropsdev Thanks for the update and the syntax help.
Forgot to post an update on what also got me through.
$Users = Get-AzureADUser -Filter "AccountEnabled eq false"#Remove-AzureADUserManager -ObjectId $Users[0].ObjectId
foreach ($User in $Users) {
Remove-AzureADUserManager -ObjectId $User.ObjectId
}
Two things: Be careful using Azure AD Powershell if you're planning for this script to be run regularly, because it will be decommissioned at the end of this year.
Second, you can do just pipe the results of the first command through like this:
Get-AzureADUser -Filter "AccountEnabled eq false" | Remove-AzureADUserManager
raindropsdev Thanks for the update and the syntax help.
Forgot to post an update on what also got me through.
$Users = Get-AzureADUser -Filter "AccountEnabled eq false"
#Remove-AzureADUserManager -ObjectId $Users[0].ObjectId
foreach ($User in $Users) {
Remove-AzureADUserManager -ObjectId $User.ObjectId
}