Monday, 18 May 2015

Managing Office 365 using Powershell

Introduction

Powershell is an incredibly powerful tool that if you're not already using it and you're a Windows Systems Administrator you will want to make it a priority. It is even more necessary if you are considering making the jump to Office 365. Microsoft does not give you access to the back end management software for Exchange (ESM), or SharePoint (Central Administration). Instead there is a chopped down web interface that provides you with the basics, and Powershell is used to fill in the gaps. Gaps like, giving editing rights to a shared calendar and many more.
There are a few steps that you will need to take before you can start using Powershell to manage your Office365 domain.

 

Prerequisite software

OS:
Windows 7, Windows 8, Server 2008 R2, Server 2012, or Server 2012 R2
Powershell:
If you're running Win7 or newer you will have Powershell all ready installed. If not you will need to download and install it. You can get Powershell 4.0 here: http://www.microsoft.com/en-us/download/details.aspx?id=40855. Warning, if you're managing Exchange 2010 or earlier on premise with Powershell you will need to use Powershell 2.0.
.NET Framework:
You have to have .NET Framework 3.51 installed.
Microsoft Online Services Sign-in Assistant:
You will need this small piece of software installed to be able to connect to Office365. It is also necessary for running the Lync client on your desktop. You can download it here:
http://go.microsoft.com/fwlink/?LinkId=286152

Install Office 365 Cmdlets/AD Azure Module

The next thing that you will need is access to the Office365 cmdlets so that you will have the commands that you need to manage your domain. You will need to download and install these files:
32 bit - http://go.microsoft.com/fwlink/p/?linkid=236298
64 bit - http://go.microsoft.com/fwlink/p/?linkid=236297

If you're running a 64bits computer:
Copy the folder MSOnline from (1) –> (2) as seen here
1) C:\Windows\System32\WindowsPowerShell\v1.0\Modules(MSOnline)
2) C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules(MSOnline)

Scripting your connection

Once you have finished the above you're ready to actually connect to your Office365 domain. Here is the syntax that you will need to run:
Import-Module MSOnline
$O365Cred = Get-Credential
$O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection 
Set-ExecutionPolicy RemoteSigned
Import-PSSession $O365Session -AllowClobber
Connect-MsolService –Credential $O365Cred

Command to disconnect your session after your work:
Remove-Module MsOnline

Handy Power Shell Commands
https://drive.google.com/open?id=0Bwl5ORajpx3GdGJQWFdMeVlMNWs&authuser=0 

No comments:

Post a Comment