We all like the user interfaces and are using that daily but we all know that running some tasks in PowerShell is inevitably. We need to administrate all the Office 365 services with PowerShell. It can get frustrating to start modules, snappins or whatever and logon every morning since it cannot be done in a one shot line.
As a matter of fact, with all different connection methods, it would appear that you need to use five different PowerShell instances in order to handle all Office 365 services. How can we avoid this and make it a lot easier to connect?
It’s possible to access all services through one console. Starting it up with a script makes it a lot easier too.
There are some requirements on the computer you are trying to access from. It has to be a Windows 7 SP1, 8, 8.1, 10 or Windows 2012/2012 R2. I suggest you are running Windows 10 on a local machine or Windows 2012 R2 if running on a management server and x64 ofcourse.
Download and install the following files:
• Microsoft Online Service Sign-in Assistant for IT Professionals RTW
• Windows Azure Active Directory Module for Windows PowerShell (64-bit version)
• SharePoint Online Management Shell
• Skype for Business Online, Windows PowerShell Module
Open a PowerShell console in admin mode and type:
1. Set-ExecutionPolicy RemoteSigned
2. $cred = Get-Credential
3. $cred | Export-Clixml -Path “C:ScriptsonlineCred.xml”
When saving the credentials like this be aware of that the script is login in with the credentials automatically, use with caution.
Save these lines into a O365PowerShell.ps1 file on the same path as when generating logon
$cred = Import-Clixml -Path "c:scriptsonlineCred.xml" # MS Online Import-Module MsOnline Connect-MsolService -Credential $cred #Sharepoint Online, change altitude365 to your domain Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking Connect-SPOService -Url https://altitude365-admin.sharepoint.com -credential $cred #Skype4B Online Import-Module SkypeOnlineConnector $S4BSession = New-CsOnlineSession -Credential $cred Import-PSSession $S4BSession #Exchange Online $EXOSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication "Basic" -AllowRedirection Import-PSSession $EXOSession –DisableNameChecking #Compliance Center #Since cmdlts in Exchange Online and Compliance Center collide, we add a prefix 'CC' to all commands that refer to compliace center $CCSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $CCSession -Prefix CC
Now, open a PowerShell in privileged mode and run the script and get to work!