Oct 01 2022 11:31 AM
Hi Community,
Currently working on a request for Teams org chart to display updated information.
#Purpose of this script is to cleanup the organization teams chart. I need to remove manager from all disabled users in azure for it reproduce in Teams.
The command below works but I am having trouble pushing it to all filtered disabled accounts
$User = Get-AzureADUser -Top 1
Remove-AzureADUserManager -ObjectId $User.ObjectId
This is how I currently have the Syntax formatted
Get-AzureADUser -Filter "AccountEnabled eq false" -Remove-AzureADUserManager -ObjectId $user.ObjectId
Please provide any guidance, a true rookie.
Thanks
Oct 01 2022 11:31 AM
Oct 04 2022 02:30 AM
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
Oct 04 2022 07:57 AM
Solution@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
}
Oct 04 2022 07:57 AM
Solution@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
}