Share via

How to setup AD user's manager using az module?

Anonymous
2022-10-11T12:05:51.44+00:00

Hello

I'm trying to automate our new user creation in AD using AZ module with powershell.

We are using mac computers so all modules are not allowed but AZ module is.
I'm able right now to create user and link them to some groups and this is great.

Howerver, I do not know how to declare the manager of the new user.

All the way I found is using the set-aduser command that seems to not be available on mac.
I do not find anything neither using the API.

Your help could be very helpful.

Thanks.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments

Answer accepted by question author

Vasil Michev 127K Reputation points MVP Volunteer Moderator
2022-10-11T13:12:14.517+00:00

Use the Microsoft Graph SDK for PowerShell, which runs fine on PS Core and non-windows devices: https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation?view=graph-powershell-1.0
Once installed/connected, run the following cmdlet:

Set-MgUserManagerByRef -UserId ******@domain.com -BodyParameter @{ "@odata.id"= "https://graph.microsoft.com/v1.0/users/584b2b38-4321-1234-8888-c9766cb4791b"}  

where you need to designate the manager as a reference object. Basically, you need to get the objectID and prepare it as input for the hashtable. I know, it's a crappy format, but that's what you get when Microsoft cannot be bothered to release proper cmdlets and relies on autogenerated crap.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.