Is there a way to Create a context in powershell using Client Id and Client Secret ?

Currently I am using $context.Credentials in my code.

1 Answer 1


You can use PnP PowerShell to connect to SharePoint using client id as below:

Connect-PnPOnline -Url <url> -AppId <clientid> -AppSecret <clientsecret>
$context = Get-PnPContext

Reference - Connect-PnPOnline

Download - PnP PowerShell releases

If you have PowerShellGet installed, you can directly install it using Install-Module SharePointPnPPowerShellOnline

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.