Office 365 is designed to be very oriented to Windows PowerShell and in fact that not all administration tasks are available through the Office 365 Administration Portal’s Graphical User Interface (GUI), but they are all available through PowerShell. Therefore, Windows PowerShell is the superset administration tool and a definite requirement in your toolkit.
In addition of PowerShell we also need Windows Azure AD Module and Windows PowerShell Integrated Scripting Environment (ISE)
Before we download and install Windows Azure AD Module we need to install Microsoft Online Services Sign-in Assistant.
Download Online Services Sign-in Assistant latest version from here. After you will install it next we need to install Windows Azure AD Module you can download latest from here http://aka.ms/aadposhand read latest updates in documentation.
OK, after downloading and installing all components lets try to connect to our Office 365 subscription there is no difference in connection and using in Trial or Regal Subscription, if you do not have subscription yet, register your trial from here
Find in programs or on your desktop Windows Azure Active Directory Module for Windows PowerShell and run it.
All we need to connect to our Office 365 is:
$cred = Get-Credential
Connect-MsolService -Credential $cred
after entering you credentials, lets try some command, lets check our subscription status
So that’s all, we are connected from PowerShell, you can also save command to .ps1 file for later use, and do not forgot to Set-ExecutionPolicy –ExecutionPolicy Unrestricted otherwise you will get errors running .ps1 file.
The same way you can use commands and script that you saved in .ps1 in Windows PowerShell Integrated Scripting Environment (ISE). We will use later PowerShell ISE for easy management.
For administering Exchange you might want to import cmdlets
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic –AllowRedirection
It is important that you close a PSSession after you are done. The reason for closing a PSSession is because of the connection limit in place as a security measure. If you do not close a PSSession, you will need to wait for the session to time out. If there are five sessions of PSSession open, you will not be able to establish additional sessions
That’s it for now I will continue post about PowerShell and Office 365
In addition try this Office 365 Helper Scriptsit will help you to understand and prepare for future advanced administering of Office 365