Home > Office365 > Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 01

Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 01


office365_thumb

 

Windows PowerShell is a task-based command-line shell and scripting language designed for system administration. As an Matured Systems Administrator Smile  you can use rich PowerShell commands to perform many more Microsoft Office 365 Administration tasks such as manage users, groups, role memberships, service principals, domains and ect. In my previous blogs I have mentioned some PS comdlets to carryout some tasks and errors you would get during the administration tasks. Below series of articles provide you descriptive information with screenshots about Windows PowerShell cmdlets for Office 365.

Prior to get familiarized with cmdlets you should install prerequisites attached below, You can go through the installation steps to install below tools which I posted in the my previous blog post.

  • Operating System – you’ll need to be running Windows 7 or Windows Server 2008 R2
  • .NET Framework – the 3.5.1 version of the .NET Framework needs to be installed

Microsoft Online Services Sign-in Assistant

Install Microsoft Online services module for windows PowerShell

How to connect to MS Online using PS :

Use below PS command to Import MSonline Module and Log in to Microsoft Online tenant account.

Import-Module MsOnline

 

image

 

Connect-MsolService

image

 

~Get-MsolUser~

This cmdlet is used to retrieve Information about Microsoft Online Users.An individual user will be retrieved if the Object ID or UserPrincipalName parameter is used.

 

Untitled

 

~New-MsolUser~

This cmdlet is used to create a new user in the Microsoft Online directory. In order to give the user access to services, they must also be assigned a license (using the LicenseAssignment parameter) and also it is not a must to use –Password  parameter and if you do not use, system will automatically generate a temp password and will display under the Password tab.

 

As I mentioned you have LicenseAssignment parameter, you can retrieve it using below PS command.

 Get-MsolAccountSku

 

image

 

New-MsolUser -UserPrincipalName dilshansam@valakulu.net -DisplayName ‘Dilshan Sam’ -FirstName Dilshan -LastName Sam -LicenseAssignment msdivision:ENTERPRISEPACK -UsageLocation lk -Password Password1

 

image

 

PS Command without –Password  parameter. As you can see system generated a temp password for the created user.

 

New-MsolUser -UserPrincipalName dilshansam@valakulu.net -DisplayName ‘Dilshan Sam’ -FirstName Dilshan -LastName Sam -LicenseAssignment msdivision:ENTERPRISEPACK -UsageLocation lk -Password Password1

 

Untitled

 

After you have enter the PS cmdlet you can go to Administration Portal and view the created User.

 

image

 

~Assign Customized License Plan~

Each Microsoft Office 365 Plan contain a subset of service plans. when viewing the licensing settings in the Microsoft Online Services Portal for user assigned license you will see subset of services under the Assign Licenses. Subsets can be changed with the license type which the user have purchased.

Instead of assigning all of the service plans available with the license, you may only need to assign a subset of these, such as Office Professional Plus and Exchange Online. In order to do this from the shell, you’ll need to be able to view the service plan information to retrieve what your options are. Below command will provide you plan details for the EnterprisePack sku. so you again turn to the Get-MsolAccountSku cmdlet. Here’s a one-liner that will provide below information.

Get-MsolAccountSku | Where-Object {$_.SkuPartNumber -eq 'ENTERPRISEPACK'} |
   ForEach-Object {$_.ServiceStatus}

 

Are you shocked about the service Plan description? Smile It is obvious you get shocked by seeing the description. Here I have break down of what each of these really are,

 

Untitled

 

Here we go now we do have required service plan details. Now you can modify license option you have selected for each individual user and also you can select customized service plan for new user provisioning processes. At first will see how to assign customized service plan for newly creating user.

 

Customized service plan for already created user

I have selected all service license plan for previously created dilshansam@valakulu.net user and now I need to customize it to use only Office Professional Plus and Exchange Online licenses. In order to do that, we’ll need to create a LicenseOption object using the New-MsoLicenseOptions cmdlet. When running the cmdlet, we specify the account sku id, which in this case would be in the format of tenant:ENTERPRISEPACK, and then we disable the service plans that we do not want to be include in the object. You can achieve this by disabling service plans that you do not want to be include in the user object using DisabledPlans parameter. As you can see below the resulting LicenseOption object is saved to the $options variable, which can then be assigned to theLicenseOptions parameter when modifying the account:

 

$options = New-MsolLicenseOptions -AccountSkuId msdivision:ENTERPRISEPACK -DisabledPlans MCOSTANDARD,SHAREPOINTWAC,SHAREPOINTENTERPRISE

 

PS>Set-MsolUserLicense -UserPrincipalName dilshansam@valakulu.net -LicenseOptions $options

 

image

 

Customized service plan for new user

New-MsolUser -UserPrincipalName dilshansam@valakulu.net -DisplayName ‘Dilshan Sam’ -FirstName Dilshan -LastName Sam -LicenseAssignment msdivision:ENTERPRISEPACK -LicenseOptions $options -UsageLocation lk

 

image

 

In my next article I will show you how to carryout Bulk licensing and Provision bulk user accounts using a CSV file. 

Hope this article helpful for you guys… Smile

Windows PowerShell cmdlets for Office 365 ~ Manage Users – Part 02

Advertisements
Categories: Office365

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: