Office-docs-powershell: ClientId samples do not work as expected

Created on 20 Aug 2019  Â·  9Comments  Â·  Source: MicrosoftDocs/office-docs-powershell

When working to Connect using AzureAD App Only, the following combination is the only thing that works for me:

Connect-PnPOnline -Url $adminUrl -Tenant "<tenant>.onmicrosoft.com" -CertificatePath <PATHTO>.pfx -ClientId $azureApplicationId -CertificatePassword (ConvertTo-SecureString -AsPlainText $azureApplicationIdPassword -Force)

This seems a bit off compared to the docs as I need to provide Client ID, Cert Path, and Cert Password here. Without the Cert Path, I get the following:
Connect-PnPOnline : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:18

Why is the certificate even necessary?

I have tried the following paths as suggested in the docs with no success:

PS CMD:
Connect-PnPOnline -Url $adminUrl -ClientId $azureApplicationId -Tenant "<tenant>.onmicrosoft.com" -CertificatePath <PATHTO>.pfx

Result:
Connect-PnPOnline : The specified network password is not correct.

PS CMD:
Connect-PnPOnline -Url $adminUrl -ClientId $azureApplicationId -Tenant "<tenant>.onmicrosoft.com" -Thumbprint "<AZURETHUMB>"

RESULT:
Connect-PnPOnline : Value cannot be null.
Parameter name: certificate


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

All 9 comments

@officedocsbot assign @yogkumgit

Hello @cperson there is currently an open issue about this, here https://github.com/SharePoint/PnP-PowerShell/issues/2181 please follow up there

Hello @cperson there is currently an open issue about this, here SharePoint/PnP-PowerShell#2181 please follow up there

Thanks. I believe this is still valid, however, as this issue is geared specifically towards the inacurracy of the docs.

Hello @cperson there is currently an open issue about this, here SharePoint/PnP-PowerShell#2181 please follow up there

Thanks. I believe this is still valid, however, as this issue is geared specifically towards the inacurracy of the docs.

I understand your point however the Docs reflect the desired behavior, and as the functionality is in the process of being fix, I do not see anything to change in the article.

I will add a message to that issue to get the attention of the PnP team, that, as you might know, it is maintained by the community.

Hello @cperson there is currently an open issue about this, here SharePoint/PnP-PowerShell#2181 please follow up there

Thanks. I believe this is still valid, however, as this issue is geared specifically towards the inacurracy of the docs.

I understand your point however the Docs reflect the desired behavior, and as the functionality is in the process of being fix, I do not see anything to change in the article.

I will add a message to that issue to get the attention of the PnP team, that, as you might know, it is maintained by the community.

While the docs intentions are good, the docs are _wrong_. I don't think it's ideal to close _this_ issue before _that_ issue is resolved. Leaving this issue open will hopefully prevent other users relying on the Docs from going down a rabbit hole.

"Hov did that so hopefully you won't have to go through that" - Jay-Z

Hi,
I'll look at the examples and try to clean them up.

For app-only SharePoint access you need a certificate - that's just how it is.

You either need to point to a certificate path, a certificate thumbprint, or provide the values using the PEM values inline.

See https://github.com/SharePoint/PnP-PowerShell/tree/master/Samples/SharePoint.ConnectUsingAppPermissions for how to set up a certificate with an AAD application. If your certificate has a password, then this has to be included as well.

Example 16 has a link to this sample.

I'll add some more samples in the help on Connect-PnPOnline, matching the sample documentation, to make this easier.

@cperson I've updated the help docs with two new samples taken from the above linked documentation which will be updated for next release.

@wobba Thank you very much for the contribution and sharing this explanation. @cperson
Hope this comment is helpful for you. Thanks for taking out some time to open the issue. Appreciate and encourage you to do the same in future also.

@officedocsbot close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BlasMS picture BlasMS  Â·  5Comments

KoenZomers picture KoenZomers  Â·  3Comments

federico-r-figueredo picture federico-r-figueredo  Â·  5Comments

tomlarse picture tomlarse  Â·  5Comments

Archehandoro picture Archehandoro  Â·  4Comments