Getting started with Office 365 and Powershell can be a bit confusing, partly because so many aspects have changed in a short time. This is really for my own notes, but I’ve made it generic and may help others:
Here’s a very brief rundown on how to set yourself up and start creating cloud users. For internal users, DirSync/AzureAD is a much better option, but you may have requirements for external parties to access your Office 365 environment in some way.
Install Microsoft Online Services Sign-In Assistant for IT Professionals
Install Azure AD Module
Launch Azure Active Directory PowerShell
Test connectivity to Azure/Office365 by adding account using command “connect-msolservice” – will get prompted for credentials.
Check you’re connected with a command such as “Get-MsolCompanyInformation”
Create a CSV with your users such as this:
DisplayName,FirstName,LastName,Password,EmailAddress,UserPrincipalName
Richard Sole,Richard,Sole,ILovePSv4,r.sole@contoso.com,r.sole@mydomain.onmicrosoft.com
Connect-MsolService $data = import-csv -path C:\Temp\myusers.csv foreach ($user in $data){ New-MsolUser -FirstName $user.FirstName -DisplayName $user.DisplayName -LastName $user.LastName -Password $user.Password -UserPrincipalName $user.UserPrincipalName -UsageLocation AU }
Users are now created in Office 365!
Leave a Reply