Basic Office 365 PowerShell Tip

I'm setting a new PC this week and getting used to a different keyboard, joy. I connect to Office 365 Exchange Online a lot, so the first for me is to run the following.

Using an elevated PowerShell window.

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Next I register my scripts directory in PS.

$env:path = $env:path + ";C:\Scripts\PowerShell"

Then to create my most used script, I save it as O365Session.ps1.

$O365PSSess1 = New-PSSession -ConfigurationName -ConnectionUri -Credential (Get-Credential) -Authentication basic -AllowRedirection
Import-PSSession -Session $O365PSSess1

To run I just open a PowerShell session window and type O365Session.ps1.

This post is really just a reminder for me, I hope that if you didn't know about this you have now tried it.