In order to manage Office 365 via Remote PowerShell, there are a number of commands required. For anyone finding themselves jumping in and out of a remote powershell session, or moving between multiple tenants, continuously going through the authentication commands can be tedious. Upon opening a standard PowerShell command prompt via Windows 7, the following commands are run to authenticate:
$cred = get-credential
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
$importresults = Import-PSSession $s
Rather than typing this in to a PowerShell command prompt every time I want to connect, I instead added all of these commands in Notepad and saved the file as a .ps1. Additionally, I’ve set my Execution Policy to allow unrestricted scripts (set-executionpolicy unrestricted). Now, when I want to connect, all I have to do is drag and drop my MSOnline.ps1 file in to PowerShell, fill in the appropriate Office 365 administrator credentials, and I’m logged in and ready to go.