Microsoft 365 : Detailed steps using Connect-PnPOnline with Client ID and X509 certificate

PowerShell - Connnect-PnPOnline - using ClientID and Certificate
PowerShell - Connnect-PnPOnline - using ClientID and Certificate

Hi All,

Greetings for the day!!!

Today sharing small PowerShell script but very useful.

Background

Different approach

  • One other choice is to use – Client ID and Client Secret key
Connect-PnPOnline -Url https://knowledgejunction1.sharepoint.com/sites/TestLogoFromSiteDesign -ClientSecret fM28Q~yg21IbuJ6fPpm_3ytXOfMq6xzLNoM-NdkK -ClientId 26e9ef69-eafe-4689-b35e-c397653c9b91

  • But, this approach uses legacy authentication and provides the limited functionality.
  • We will get warning as well. Please have a look image below.
 PnP PowerShell - executing CMDLET Connect-PnPOnline using client id and secret key
fig : PnP PowerShell – executing CMDLET Connect-PnPOnline using client id and secret key

Recommended approach

  • Use client application (appid / clientid) and X509 certificate.
  • To create Azure App we can use PowerShell CMDLET – Register-PnPEntraIDAppForInteractiveLogin
Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "LIFE IS BEAUTIFUL" -SharePointDelegatePermissions "AllSites.FullControl" -Tenant knowledgejunction1.onmicrosoft.com -Interactive

$SiteURL = "https://knowledgejunction1.sharepoint.com/sites/sitewithpowershell"

Connect-PnPOnline -Tenant <My Tenant ID> -Url $SiteURL 
    -ClientId <My Client ID> -Thumbprint <ThumbPrint of certificate>
PowerShell - Connnect-PnPOnline - using ClientID and Certificate
fig : PowerShell – Connnect-PnPOnline – using ClientID and Certificate

Thanks for reading 🙂 HAPPY SHARING 🙂 ENJOY BEAUTIFUL LIFE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

2 Responses

  1. January 25, 2025

    […] We have detailed article on using Connect-PnPOnline using with certificate and client id. Microsoft 365 : Detailed steps using Connect-PnPOnline with Client ID and X509 certificate – https://knowledge-junction.in/2024/11/19/m365-steps-for-connect-pnponline-clientid-n-x509-certificat&#8230; […]

  2. February 9, 2026

    […] Microsoft 365 : Detailed steps using Connect-PnPOnline with Client ID and X509 certificate […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading