Comments on: Creating New Microsoft 365 Accounts with PowerShell https://practical365.com/create-new-microsoft-365-account-powershell/ Practical Office 365 News, Tips, and Tutorials Thu, 14 Sep 2023 13:59:16 +0000 hourly 1 https://wordpress.org/?v=6.3.2 By: Tony Redmond https://practical365.com/create-new-microsoft-365-account-powershell/#comment-274611 Thu, 14 Sep 2023 13:59:16 +0000 https://practical365.com/?p=55597#comment-274611 In reply to Srdjan.

I could sell you a copy of the Office 365 for IT Pros eBook, where all of this is discussed in chapter 23.

But https://practical365.com/azure-ad-account-creation-standardization/ has an example of an auto-generated password for use with New-MgUser. There are other examples available on the net.

As to assigning a license along with the account, there is an AssignedLicenses parameter for New-MgUser https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.users/new-mguser?view=graph-powershell-1.0 Have you tried using that?

]]>
By: Srdjan https://practical365.com/create-new-microsoft-365-account-powershell/#comment-274608 Thu, 14 Sep 2023 13:36:02 +0000 https://practical365.com/?p=55597#comment-274608 Hi Tony, I’m in the process of migrating new MSOL scripts. However, I find it a bit difficult, because I can’t seem to find switches in Microsoft Graph that we had in MSOL.

Let me elaborate…

First, I create the hash table using the example you specified.

After a bit of testing and studying the examples you provided on this page, I created this cmdlet for creating new user:

New-MgUser -DisplayName “New user” -GivenName “New” -Surname “User” -UserPrincipalName “New.User@domain.com” -UsageLocation RS -PasswordProfile $NewPassword -AccountEnabled -MailNickName New.User | Export-Csv -Path G:\Office365_Graph\MS-graph-test1.csv -Encoding Unicode -Append

and after that I run this one to assign a license to the newly created user:

Set-MgUserLicense -UserId “New.User@domain.com” -Addlicenses @{SkuId = ‘MY-SKU-NUMBER’} -RemoveLicenses @()

This works as a charm, but I’d like to tweak it a bit more:

1. I would like to be able to force M365 to auto-generate password for that user (just like the old New-MsolUser command did it), so that I end up with CSV report that has usernames and auto-generated passwords. I am afraid that having a lot of users with the same initial password could be risky.

2. I would like to avoid running separate Set-MgUserLicense cmdlet and incorporate it into the New-MgUser cmdlet.

Can you think of something regarding those two, maybe you have a few tricks on your mind? 🙂

Best regards,
Srdjan

]]>
By: Martin https://practical365.com/create-new-microsoft-365-account-powershell/#comment-238627 Wed, 25 May 2022 18:28:47 +0000 https://practical365.com/?p=55597#comment-238627 Thanks for this helpful and great blog post !

]]>