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.
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