If you do this frequently, you can add it as a function to your PowerShell profile. Open your profile in a text editor or PowerShell ISE, and add the following.

1. Check if a remote Powershell session exists

The first step is to create a Remote PowerShell session to Exchange Online or your on-premises Exchange Server. But before you do that, it makes sense to check if a session already exists. I use the EXO function to connect to Exchange Online, and the EXOSessionExists function to check if there’s an existing session. If a session doesn’t exist, it creates one.

You can use it for any other scripts or functions that require a RPS session to Exchange Online or Exchange Server. Add them to your PowerShell profile.