Adding Multiple Users to Administrative Units

Hi All, I’d love some direction on how to accomplish what I’m trying to do.

I’m following the instructions here https://docs.microsoft.com/en-us/powershell/module/msonline/add-msoladministrativeunitmember?view=azureadps-1.0#required-parameters

However, for $User, instead of Get-MsolUser -UserPrincipalName “[davidchew@contoso.com](mailto:davidchew@contoso.com)” I’m doing Get-MsolUser -DomainName “contoso.com” so I can all the members of that domain to the AU. However, I’m getting the following error:

Add-MsolAdministrativeUnitMember : Cannot convert ‘System.Object[]’ to the type ‘System.Nullable`1 [System.Guid]’ required by parameter ‘AdministrativeUnitMemberObjectId’. Specified method is not supported.

At line:1 char:124

  • … d $AdminstrativeUnit.ObjectId -AdministrativeUnitMemberObjectId $User
  • CategoryInfo : InvalidArgument: (:) [Add-MsolAdministrativeUnitMember], ParameterBindingException
  • FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Online.Administration.Automation.AddAdministrativeUnitMember

I’m assuming it’s because the $user variable had more than one objectID associated to it. Any idea how to get around it so I dont have to add them all individually?

submitted by /u/wh15p3r
[link] [comments]

Leave a Reply