SOLVED

connect-pnpmicrosoftgraph Has Been Deprecated

Brass Contributor

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

image.png

 

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?

10 Replies

I'm using the following and it works fine.

 

Connect-PnPOnline $tenantUrl -UseWebLogin

Doesn't that require user interaction?

it depends, i entered my credentials and told the browser to keep me logged in several days ago, and have not logged in since

 

This is an automated script. I won't be logging in at anytime. That's why I set up the application.  

Sorry, can't help you any more, I have had to do a lot of trial and error with the various connection parameters to figure out what works for my customers tenants

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'"...

best response confirmed by VI_Migration (Silver Contributor)
Solution

So - after downloading the latest version of Sharepoint PNP for Online it works as expected!

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.

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.

Ha! Got it. I just ran an install of the code rather than an update

install-Module SharePointPnPPowerShellOnline -force -SkipPublisherCheck

 

1 best response

Accepted Solutions
best response confirmed by VI_Migration (Silver Contributor)
Solution

So - after downloading the latest version of Sharepoint PNP for Online it works as expected!

View solution in original post