We recently migrated from SharePoint 2013 to SharePoint Online.
We have a existing job in SQL Server which run with proxy service account and which call power shell script (PnP cmdlet) to connect Share Point and get the List Item data. This process is working as expected.
The existing code have : ConnectPnPOnline -url "xxxx" -currentcredentials
The currentcredentials is taking up the proxy service account details and the same account have permission on share point.
Share Point Online acceps on SSO , so i provided ConnectPnPOnline -url "xxxx" -useweblogin but it popup window and asking for credentials. I should not have any user interaction as i am calling this script from scheduled sql job.
How to provide bound SSO (single sign on) credentials in the power shell script.
Or, any other approach to fullfill my requirement.
Tuhin PaulPosted Feb 17, 2023, 8:04 PM
Hi Mohan,
In order to use SSO with SharePoint Online and avoid the popup window asking for credentials, you can use the Azure Active Directory (Azure AD) application authentication method. Here are the steps to achieve this:
Step 1, you need to register a new Azure AD application in the Azure portal. This application will represent the client application that will access SharePoint Online. Note the Application ID and Tenant ID as you will need them later.
Step 2, you need to grant permissions to the Azure AD application to access SharePoint Online. To do this, you can use the SharePoint Online Management Shell to execute the following PowerShell script:
This script enables custom app authentication and allows you to grant permissions to the Azure AD application.
After running the above script, you can grant permissions to the Azure AD application by executing the following PowerShell script:
Replace the ApplicationId, ApplicationSecret and TenantId values with the corresponding values from the Azure AD application that you registered.
Step 3, you can modify your PowerShell script to use the Azure AD application instead of the current credentials. Here is an example of how to connect to SharePoint Online using the Azure AD application:
May be this way you can run your PowerShell script in a scheduled SQL job without any user interaction.