Powershell Profiles Make Life Easier !
The five commands that connect you into the cloud are indeed a big block of text.
Import-Module MSOnline $O365Cred = Get-Credential $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $O365Cred -Authentication Basic -AllowRedirection Import-PSSession $O365Session Connect-MsolService –Credential $O365Cred
There purpose is broken down as follows…
1. Import your newly installed Online Services module
2. Enter Office 365 credentials
3. Create a remote session
4. Import that session’s commands into your local Windows PowerShell session
5. Connect to Office 365 services
Retyping that text block every time you log in can make working with Windows PowerShell seems like more effort than it’s worth, Right ? Well here’s something useful….
Every time a Windows PowerShell session begins, it will run whatever commands it finds in a special file referenced by the variable $profile. You can view where that file exists by running dir $profile in the shell.
The $profile command brings you to a file similar to Microsoft.PowerShell_profile.ps1 You can edit this document in your favourite text editor to add to the five connection commands. Now every time you launch Windows PowerShell, you need only enter username and password to be automatically connected into Office 365, as well as everything else on your network.