How to activate synced users bulky in Office 365

Introduction

This script is used to help administrators to activate synced users bulky in Office 365.

Scenarios

This script is used to help administrators to activate synced users bulky in Office 365


Script

You can use this script in the following way.

1. Open Windows PowerShell.

2. Type the command< Script Path> at the Windows PowerShell Console.

For example, type C:\Script\ ActiveSyncedUserO365.ps1

Here are some code snippets for your reference.

 

PowerShell
Edit|Remove
$Users = Get-MsolUser -UnlicensedUsersOnly  
$SKU = Get-MSOLAccountSKU 
if($SKU.count -gt 1) 
{ 
    Foreach($User in $Users) 
    { 
        Set-MsolUserLicense  -UserPrincipalName $User.UserPrincipalName -AddLicenses $SkU.AccountSkuId 
    } 
} 
elseif($SKU.count -eq 1) 
{ 
    $i = 0 
    do 
    { 
        Write-Host "$i,$($SKU[$i].AccountSkuId)" 
        $i++ 
    }while($i -le $SKU.count-1) 
    [int]$userChoice = Read-Host "Please choose the License to active the synced users" 
    Foreach($User in $Users) 
    { 
        Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $SKU[$userChoice].AccoutSKUId 
    } 
} 

Examples

       Example1: Activate synced users bulky in Office 365.

ActiveSyncedUserO365.ps1

Prerequisites

Exchange Online
Windows PowerShell 2.0

Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.