Issue when running Add-PnPTeamsTeam. In the background this commandlet is using the following SharePoint API /_api/groupsitemanager/EnsureTeamForGroup to create a new team for this sitecollection.

Expected behavior

Connecting a newly created team to the connected sitecollection

Actual behavior

Add-PnPTeamsTeam is throwing an odata error with the following text

Add-PnPTeamsTeam : {"odata.error":{"code":"10001","message":{"lang":"nl-NL","value":"AADSTS700082: The refresh token has expired due to inactivity.\u00a0The token was issued on [date] and was inactive for

Steps to reproduce behavior

  1. Connect-PnPOnline -Url [SiteCollectionUrl] -Credentials (Get-Credential)
  2. Add-PnPTeamsTeam

Steps performed to solve this problem

  • Revoke-AzureADUserAllRefreshToken
  • Revoke-AzureADSignedInUserAllRefreshToken
  • Revoke-SPOUserSession

All of those commandlets don't refresh the refresh token within SharePoint Online.

1 Answer 1


Please use the New-SecMgmtAccessToken cmdlet to acquire an access token from Azure Active Directory.

For more information, refer to:


  • Thanks for you're feedback, but acquire an access token is not the issue for my opinion. We need to have a new "refresh token" from Azure AD. Connecting with the above command-let gives finally a page with the following error: AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application. The reply URL specified is the following: https://[tenant].sharepoint.com. Is this correct when register an application in Azure AD?
    – Mark Gort
    Commented Nov 3, 2020 at 15:17
  • - $credential = Get-Credential - New-SecMgmtAccessToken -ApplicationId 'xxxx-xxxx-xxxx-xxxx' -Scopes 'graph.microsoft.com/.default' -ServicePrincipal -Credential $credential -Tenant 'yyyy-yyyy-yyyy-yyyy' -UseAuthorizationCode
    – Mark Gort
    Commented Nov 3, 2020 at 15:17
  • I could reproduce your issue per my test, still show the error, the refresh token expired, I suggest you open a ticket with Microsft to check if there is something error with the command.
    – Julie_MSFT
    Commented Nov 6, 2020 at 10:02
  • Facing the same issue. Using: Connect-PnPOnline -Url [SiteCollectionUrl] -UseWebLogin and then Add-PnPTeamsTeam does work. But we need to use CredentialManager becase of automated install
    – Danny
    Commented Nov 11, 2020 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.