Connect to Office 365 from PowerShell

It was somewhat hard to find the necessary software to manage Office 365 from the command line. There are different versions available. To make life easier here follows a shopping list to make your pc ready for PowerShell and Office 365.

.NET Framework 4.5
http://www.microsoft.com/en-us/download/details.aspx?id=30653

PowerShell 4 (Windows Management Framework 4)
http://www.microsoft.com/en-us/download/details.aspx?id=40855

Microsoft Online Services Sign-in Assistent v7
http://www.microsoft.com/en-us/download/details.aspx?id=41950

Windows Azure Active Directory Module
Windows Azure Active Directory Module for Windows PowerShell (32-bit version)
Windows Azure Active Directory Module for Windows PowerShell (64-bit version)

After installing and rebooting start the Windows Powershell ISE (run powershell_ise.exe; it’s in the path variable). Then use these commands to test and connect to your Office 365 setup:

Import-Module MSOnline
if ($cred -eq $null) {
    $cred = Get-Credential
    $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection
    Import-PSSession $session
    Connect-MsolService -Credential $cred
}
if ($cred -eq $null) {
    Exit
}
Get-MsolCompanyInformation

Hope this is helpful for you! I will follow up with more useful Office 365 commands in the nearby future.

Advertisements

About Stoomkracht

Scripter, programmer, Windows administrator, network/wifi engineer, thinker

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: