Archive

Archive for the ‘Azure’ Category

Manage Office 365 User licenses with Powershell

January 13, 2017 Leave a comment

Install required Software first

  • Install the 64-bit version of the Microsoft Online Services Sign-In Assistant – LINK
  • Install the 64-bit version of the Windows Azure Active Directory Module for Windows PoweShell – LINK

PowerShell commands

# Import MSOnline Module

Import-Module MSOnline

# Connect to Office 365

$O365Cred = Get-Credential
Connect-MsolService -Credential $O365Cred

# Show Licenses

Get-MsolAccountSku

# View details about the Services that are available in all of your license plans

Get-MsolAccountSku | Select -ExpandProperty ServiceStatus

# Check which users have licenses

Get-MsolUser -All | fl DisplayName, UsageLocation,isLicensed,Licenses

# Check if a user has a license – Single

Get-MsolUser -UserPrincipalName "user.name@domain.com" | ft DisplayName, UsageLocation,isLicensed,Licenses

# Add a license – Single user

Set-MsolUserLicense -UserPrincipalName "user.name@domain.com" -AddLicenses "company:ENTERPRISEPACK"

# Remove a license – Single user

Set-MsolUserLicense -UserPrincipalName "user.name@domain.com" –RemoveLicenses "company:ENTERPRISEPACK"

# Bulk Add licenses

$Users = Import-Csv -Path "C:\Temp\licenses.csv"
foreach ($User in $Users)
{
    $UPN = $User.‘SamAccountName’ + "@zhgplc.com"
    Set-MsolUser -UserPrincipalName "$UPN" -UsageLocation "GB"
    Set-MsolUserLicense -UserPrincipalName "$UPN" -AddLicenses "company:ENTERPRISEPACK"
}

# Bulk check added licenses 

$Users = Import-Csv -Path "C:\Temp\licenses.csv"
foreach ($User in $Users)

{
    $UPN = $User.‘SamAccountName’ + "@zhgplc.com"
    Get-MsolUser -UserPrincipalName "$UPN" | ft DisplayName, UsageLocation, Licenses
}

 

-Eric

PowerShell – Azure AD Connect sync: Scheduler Command Cheat Sheet

May 13, 2016 Leave a comment

Here are some of the commands.

To view the Scheduler configuration:

Get-ADSyncScheduler

This shows you the current sync configuration information like interval, sync policy type, next sync cycle start time etc.

To change the scheduler configuration:

Set-ADSyncScheduler

This allows you to change some the following sync parameters.

  • CustomizedSyncCycleInterval
  • NextSyncCyclePolicyType
  • PurgeRunHistoryInterval
  • SyncCycleEnabled
  • MaintenanceEnabled

To Start the Scheduler manually:

There are two synchronization options – Delta and Full.
Delta – Use this when there is an urgent change that needs to be synchronized immediately.

Start-ADSyncSyncCycle -PolicyType Delta

Full – Use this when the following changes have been made.

  • Synchronization rules have been changed
  • Filtering changes, which included different number of objects
  • More attributes or objects are to be imported from source directory
    Start-ADSyncSyncCycle -PolicyType Initial
    Check the status of the connector:
    Get-ADSyncConnectorRunStatus

    If its busy and running the sync the connector name will be returned.

 

More info – Azure Documentation

-Eric