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.

up vote 5 down vote accepted

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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