Forum Discussion
Ty__AdventurousAdmin
Oct 01, 2022Copper Contributor
Removing Manager for all disabled users
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 manage...
- 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
}
Ty__AdventurousAdmin
Oct 01, 2022Copper Contributor
ERROR once ran
Get-AzureADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ObjectId'. Specified method is not supported.
At line:2 char:88
+ ... Enabled eq false" -Remove-AzureADUserManager -ObjectId $user.ObjectId
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzureADUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Open.AzureAD16.PowerShell.GetUser
Get-AzureADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ObjectId'. Specified method is not supported.
At line:2 char:88
+ ... Enabled eq false" -Remove-AzureADUserManager -ObjectId $user.ObjectId
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzureADUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Open.AzureAD16.PowerShell.GetUser