Plenty of organizations are moving to O365 these days. Extending your directory services outside of your on-premise environment can put Admins on edge. I wanted to take some time to share some Powershell that helps make administering Cloud Identities a lot less intimidating.


Who wants to RDP to a Dirsync server to manage O365? I sure don’t. Adding Microsoft Office Sign On Assistant and the following Script allows you to manage the cloud from where it was intended…anywhere. Start by grabbing and installing the bits for MOSS: This is pretty light weight and a wizard based installation. Fire up Powershell and remotely connect to the cloud with the following script:


#Import O365 cmdlets and setup your Credentials for Connecting to O365 Import-Module Msonline $Cred = Get-Credential $Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Cred -Authentication Basic -AllowRedirection Import-PSSession $Session Connect-MsolService –Credential $Cred


Create a ps1 from the code above and execute it. You should be prompted for some credentials with a prompt that looks similar to this:




Put your UPN/Password in for your Global Admin Account. Now you have a powershell session that can be leveraged to manage O365. The possibilities from here are near endless. I plan on speaking through some specific O365 provisioning scenarios in future blogs (Feel Free to Suggest Any Specific Scenarios in the Comments 🙂 ), but to wrap up today’s blog I am going to share some licensing/configuration scripts to bulk enable/configure/license all unlicensed users that have been dirsync’d.  First, we start by acquiring your MsolSku information (License) with the following command:


#Discover your License Info



#Below is the result of the Get-MsolAccountSku command


AccountSkuId                     ActiveUnits     WarningUnits     ConsumedUnits

————                              ———–           ————             ————-

companyname:SKUname    1000                          0                               0


Now that we have our License info, we can execute the following to configure all your unlicensed users with the following commands:


#Enable Login, Set Location, Set License

Get-Msoluser -UnlicensedUsersOnly | Set-MsolUser -UsageLocation US

Get-Msoluser -UnlicensedUsersOnly | Set-MsolUser -BlockCredential $false

Get-Msoluser -UnlicensedUsersOnly | Set-MsoluserLicense -AddLicenses “company:SKUname”


Let it rip and you have some users ready to use O365 🙂



About the Author: steve bowman

Three Minutes For A More Secure & Efficient Infrastructure

Short and to the point, Steve’s Email Blasts give you endpoint management tips, tricks, and news in three minutes or less email read-time, guaranteed.

Model says no to spam. Privacy Policy

Model Technology Solutions

Model Technology Solutions is a small but mighty band of infrastructure experts. We’ve helped companies in diverse industries to modernize and automate their infrastructures through effectively managing their Microsoft endpoint suite.

With us on your team, you’ll watch your security and compliance go up and your IT team’s costs (and headaches) go down. You’ll relax in knowing that your endpoints will be secure and online when your users need them most. And you’ll finally get back to your most-important tasks.

Model Technology Solutions
12125 Woodcrest Executive Drive, Ste. 204 Creve Coeur, MO 63141

Phone: (314) 254-4138
General Inquiries:
Sales and Quotes: