Connect-PnPOnline via Credentials after update to PnP.PowerShell to 2.12.0 and higher #4312
Unanswered
NatalliaKLS
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Dear Community,
after updating PnP.PowerShell to 2.12.0 we are facing issue with connecting to SharePoint Site Collection via Credentials.
We tried with 2 App Registration registered with -Interactive (Delegated API Permissions SharePoint: Sites.FullControle) and -DeviceLogin (Delegated API Permissions Site Collection: Sites.Read.All).
For the first App Registration we were able to connect via Interactive using $env:ENTRAID_APP_ID but not Credentials, for the second we consent permissions but getting error 'The user or administrator has not consented to use the application with ID '9ac60f00-e392-438a-90a2-897d698bc55e' named 'learning-ci-app'.'.
But we need to connect via Credentials after adding credentials to Windows Credential Manager, because we have to connect to a lot of Site Collections created by business users every day. And we fail using all recommended options from team PnP.PowerShell.
Below is code we are using:
To register App Registration with DeviceLogin:
$path = 'C:\Users\user\certificate'
$result = Register-PnPEntraIDApp -ApplicationName "learning-ci-app" -Tenant ***.onmicrosoft.com -OutPath $path -DeviceLogin
Connect to Site Collection:
$clientIdOwnApp = '9ac60f00-e392-438a-90a2-897d698bc55e'
$saLogin = 'user@test.com'
$saPswd = '***'
$url = 'https://domain.com/sites/devicedevlearning'
$username = $saLogin
$password = $saPswd | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Connect-PnPOnline -Url $url -Credentials $credential
In Addition: connection via clientId/clientSecret is prohibited in the company.
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions