Connecting with PnP PowerShell(without username and password)

Sezgin Tabak 86 Reputation points
2021-03-12T10:56:46.757+00:00

Dear Sir or Madam,

Is it possible to connect a site of SharePoint without creditiantials(Username, Password, pre-stored credentials using the Secrets Management, Ref. Link: https://pnp.github.io/powershell/articles/authentication.html )? Because I have required permissions for Azure AD App.

Kind Regards,
Sezgin Tabak

Azure IoT Plug and Play
Azure IoT Plug and Play
A Microsoft technology based on an open modeling language that enables developers to connect internet of things (IoT) devices to the cloud without having to write any code.
18 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,867 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,204 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,036 Reputation points
    2021-03-15T02:12:19.613+00:00

    Hi @Sezgin Tabak ,

    You could use AAD App for authentication with PnP PowerShell, you could refer to this documentation: https://zcusa.951200.xyz/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread

    In Azure AD when doing app-only you typically use a certificate to request access: anyone having the certificate and its private key can use the app and the permissions granted to the app. So you have to create and configure a self-signed X.509 certificate, which will be used to authenticate your Application against Azure AD, while requesting the App Only access token.

    The cmdlet is like the following:

    Connect-PnPOnline -ClientId <$application client id as copied over from the AAD app registration above> -CertificatePath '<$path to the PFX file generated by the PowerShell script above>' -CertificatePassword (ConvertTo-SecureString -AsPlainText "<$password assigned to the generated certificate pair above>" -Force) -Url https://<$yourtenant>.sharepoint.com -Tenant "<$tenantname>.onmicrosoft.com"  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Arijit_cloud 1 Reputation point Microsoft Employee
    2021-03-13T03:49:10.437+00:00

    The following are the some of the ways to connect to SharePoint,

    1. Using a certificate
    2. Using Azure ad app id and secret
    3. Prompt user name password (It will open a pop up for login credentials)

    Now I understand you have an azure ad app, you should be able to connect, using Client id and secret, please have a look here
    Connect-PnPOnline -Url "https://contoso.sharepoint.de" -ClientId 344b8aab-389c-4e4a-8fa1-4c1ae2c0a60d -ClientSecret $clientSecret

    Connect-PnPOnline options Reference


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.