Shortcut to Office 365 PowerShell

Working for an MSP I find myself connecting to Office 365 PowerShell multiple times per day. For the odd time, connecting manually works fine but typing (or even copying and pasting) the commands gets tedious.

A quick way to connect is to save the following as a .ps1 file and create a shortcut on your desktop to the PowerShell exe referencing the .ps1 file:

$UserCredential = Get-Credential Connect-MsolService -Credential $UserCredential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic –AllowRedirection Import-PSSession $Session

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -File "C:\Path\To\File\Office365PowerShell.ps1"

Now just double click your shortcut, enter the credentials and away you go.

Leave a Reply

Your email address will not be published. Required fields are marked *