Wednesday, January 27, 2016

Introduction to Powershell using O365 and Dynamics CRM or Dynamics Marketing

This is a first in a series of articles that will explain how to use powershell to perform different tasks in O365 related to Dynamics CRM or Marketing.

First things first, you need to have the following pre-requisites before you can proceed:

  • An O365 Account
  • CRM Online that is part of the O365 tenant.
  • At minimum, "user administrator" privileges on O365 in order to be able to assign licenses to users in O365
  • Windows Azure Active Directory Module for Windows PowerShell. Note that this is different download from the normal powershell that comes installed on your server or laptop.

Now, let's get started.
  • Right click on "Windows Azure Active Directory Module for Windows PowerShell" icon from your taskbar and choose "Windows PowerShell ISE" or in case you do not have this on your taskbar, just launch powershell and type ISE.
  • This will launch the PowerShell ISE which is the scripting environment for PowerShell. Type Connect-MsolService in order to connect to O365. This will prompt you to key in your credentials and if you have sufficient permissions, you will be able to connect to O365.
  • Once connected, you can type in various powershell commands to perform different activities. 
The following code will connect to O365 and get a list of all the subscriptions that I have in my O365 tenant along with a count of the available and consumed license units. I will then export this data to a csv file


Get-MsolAccountSku | Export-Csv D:\Srihari\O365\License\LicencesSplit.csv

The output will look something like this:

No comments:

Post a Comment