POWEROBJECTS

718 Washington Ave. N. Suite #101
Minneapolis, MN 55401
View map and all Locations

Send us a message

We’ve talked about using PowerShell to help manage your Office 365 environment. And although you can connect to Office 365 using the following commands (below), why not use something easier?

Set Powershell to Help you Log onto Office 365

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 -AllowClobber
Connect-MsolService –Credential $O365Cred

There’s a little thing called profiles. There are several locations where you can create profiles depending on your end goals.

  • This is for all users of the computer and for all shells: %windir%\system32\Windows­PowerShell\v1.0\profile.ps1
  • This is for all users of the computer, but only for the Microsoft.PowerShell shell: %windir%\system32\Windows­PowerShell\v1.0\Microsoft.Power­Shell_profile.ps1
  • This is for the current user only and all shells: %UserProfile%\Documents\Windows­PowerShell\profile.ps1
  • This is for the current user only and only for the Microsoft.PowerShell shell: %UserProfile%\Documents\WindowsPowerShell\Micro­soft.PowerShell_profile.ps1

Remember these profiles aren’t created by default. They exist only if you create them.

Using Your Profile %UserProfile%\Documents\WindowsPowerShell\Micro­soft.PowerShell_profile.ps1 to connect to office 365, create the Directory ‘WindowsPowershell’ and create the file ‘Micro­soft.PowerShell_profile.ps1’:

Now, edit the file and add the lines of code mentioned above save the file:

Now every time you start up PowerShell, you will be prompted for your credentials and then automatically be logged into Office 365.

For more PowerShell tips and tricks, check out these resources:

Increase the CRM Activity Feed Follow Limit through PowerShell

Use PowerShell to Create Reports in Office 365

Managing Office 365 with PowerShell

Happy CRM’ing!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.