Forum Discussion
Robbert van Andel
Dec 05, 2017Brass Contributor
connect-pnpmicrosoftgraph Has Been Deprecated
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?
So - after downloading the latest version of Sharepoint PNP for Online it works as expected!
- Jonas PetterssonCopper Contributor
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'"...
- Jonas PetterssonCopper Contributor
So - after downloading the latest version of Sharepoint PNP for Online it works as expected!
- Robbert van AndelBrass Contributor
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.
- Dean_GrossSilver Contributor
I'm using the following and it works fine.
$tenantUrl = 'https://tenant.sharepoint.com'Connect-PnPOnline $tenantUrl -UseWebLogin- Robbert van AndelBrass Contributor
Doesn't that require user interaction?
- Dean_GrossSilver Contributor
it depends, i entered my credentials and told the browser to keep me logged in several days ago, and have not logged in since