Connecting Powershell with Office 365 using credential manager

I use a script made by Michel de Rooij which is updated regularly. I can recommend using this script. You can find it here. I have altered this a bit so I don’t have to add my credentials every time.

One of the safest ways I could find to add my credentials without exposing them is using the credential manager in  Windows 10 or Windows Server. In the control panel you will find the Credential Manager.

You can add credentials here you can then use in PowerShell. Add a Windows Credential that you use for Authentication to Office 365. For instance a user that is also a Global Administrator in your tenant.

In PowerShell you can then reference to its name (adb_admin_cred) and store the credentials in a variable. I wrote a little function for myself to do this for me.

In a script I can then use the function and get the credential and connect to an Office 365 Service like Microsoft Teams or SharePoint Online.

Leave a Comment