Dec 05 2017
02:14 PM
- last edited on
Feb 10 2023
01:41 PM
by
TechCommunityAP
Dec 05 2017
02:14 PM
- last edited on
Feb 10 2023
01:41 PM
by
TechCommunityAP
I have a script that creates an Office 365 group and the associated SharePoint site using PnP PowerShell. I recently updated the SharePointPnPPowerShell assemblies to version 2.20.1711.0. Now I'm getting a warning that connect-pnpmicrosoftgraph has been deprecated and will be removed in April 2018.
I have found that connect-pnponline is it's replacement but I'm having trouble connecting. For connect-pnpmicrosoftgraph, I'm using
$conn = connect-pnpmicrosoftgraph -AppId $appid -AppSecret $client_secret -AADDomain "mydomain.onmicrosoft.com" -Verbose;
When I look at the details of Connect-PnPOnline with Microsoft Graph using Azure Active Directory, I see the same parameters, but running this throws an error
connect-pnponline : Value cannot be null. Parameter name: uriString At line:1 char:9 + $conn = connect-pnponline -AppId $appid -AppSecret $client_secret -AA ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], ArgumentNullException + FullyQualifiedErrorId : System.ArgumentNullException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline
Upon further investigation, it appears that AADDomain is incorrect and that I should be using url. But I'm at a loss as to what I'm supposed to use here. I've tried mydomain.onmicrosoft.com, but get an error
Connect-PnPOnline : Invalid URI: The format of the URI could not be determined. At line:1 char:1 + Connect-PnPOnline -url "mydomain.onmicrosoft.com" -AppId "xxxxxxx-xxx ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], UriFormatException + FullyQualifiedErrorId : System.UriFormatException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline
So I tried https://mydomain.onmicrosoft.com, but get this error
Connect-PnPOnline : Token request failed. At line:1 char:1 + Connect-PnPOnline -url "https://mydomain.onmicrosoft.com" -AppId "xxxx ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], RequestFailedException + FullyQualifiedErrorId : Microsoft.IdentityModel.SecurityTokenService.RequestFailedException,SharePointPnP.PowerShell.Commands.Base.Conne ctOnline
Same when I use https://graph.microsoft.com, and https://mydomain-admin.sharepoint.com
Using https://mydomain.sharepoint.com gives me a 403 forbidden error.
What is the correct replacement URL for connect-pnpmicrosoftgraph?
Dec 08 2017 01:49 PM
I'm using the following and it works fine.
Dec 08 2017 01:50 PM
Doesn't that require user interaction?
Dec 08 2017 01:53 PM
it depends, i entered my credentials and told the browser to keep me logged in several days ago, and have not logged in since
Dec 08 2017 01:55 PM
This is an automated script. I won't be logging in at anytime. That's why I set up the application.
Dec 08 2017 02:09 PM
Dec 13 2017 02:00 AM
Did you find a solution for this? I am seeing the exact same thing when I change my working config using Connect-PnPMicrosoftGraph to "Connect-PnPOnline -AppId '<id>' -AppSecret '<secret>' -AADDomain 'contoso.onmicrosoft.com'"...
Dec 13 2017 02:34 AM
SolutionSo - after downloading the latest version of Sharepoint PNP for Online it works as expected!
Dec 13 2017 11:04 AM
I updated mine just now as well. Still no luck. I'm getting the same error. I wonder what you're doing differently than me.
Dec 13 2017 11:09 AM
Although I am getting this error when I update the module
PackageManagement\Install-Package : Authenticode issuer 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'SharePointPnPPowerShellOnline' with version '2.21.1712.2' is not matching with the authenticode issuer 'CN=thawte Primary Root CA, OU="(c) 2006 thawte, Inc. - For authorized use only", OU=Certification Services Division, O="thawte, Inc.", C=US' of the previously-installed module 'SharePointPnPPowerShellOnline' with version '2.20.1711.0'. If you still want to install or update, use -SkipPublisherCheck parameter. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2089 char:20 + ... $sid = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : AuthenticodeIssuerMismatch,Validate-ModuleAuthenticodeSignature,Microsoft.PowerShell.Pac kageManagement.Cmdlets.InstallPackage
After I ran Update-Module SharePointPnPPowerShell* and got the above error, the version numbers did increase to the current version, but I'm not sure if everything installed correctly.
Dec 13 2017 11:14 AM
Ha! Got it. I just ran an install of the code rather than an update
install-Module SharePointPnPPowerShellOnline -force -SkipPublisherCheck
Dec 13 2017 02:34 AM
SolutionSo - after downloading the latest version of Sharepoint PNP for Online it works as expected!