top of page

Common O365 CmdLets

Install-Module

#Microsoft 365 PowerShell Module 

Install-Module MSOnline -Force

 

# Connect to 365 

Connect-MsolService 

logon.jpg
Set-MSOLUserLicense

#Set the license type for the user

Set-MsolUserLicense -UserPrincipalName "Dawn@ScriptsbyScott.com" -AddLicenses "ScriptsbyScott:ENTERPRISEPACK"

Get-MSOLUser -All

#List all Users and Licnese and if Licesned
Get-MsolUser -All | select UserPrincipalName,Licenses,IsLicensed,OverallProvisioningStatus 

MSOUser.PNG
Get-MSOLAccountSKU

#Get Licnese Type & Count Summary
$customformat = @{expr={$_.AccountSkuID};label="AccountSkuId"},         
@{expr={$_.ActiveUnits};label="Total"},         
@{expr={$_.ConsumedUnits};label="Assigned"},       
@{expr={$_.activeunits-$_.consumedunits};label="Unassigned"}, 
@{expr={$_.WarningUnits};label="Warning"}
Get-MsolAccountSku | sort activeunits -desc | select $customformat

License_Counter.PNG
Get-MSOLAccountSKU

#Get Service Plan and Status

Get-MsolAccountSku | select -ExpandProperty ServiceStatus

Serviuce-Status.JPG
Get-MSOLRole

#List all Azure AD Roles

Get-MSOlRole | select Name, Description

Get-MSOLROLE.JPG
Add-MSOLRoleMember

#Assign a user to a role 
Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberEmailAddress "elisadaugherty@contoso.com"

bottom of page