Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Unable to create teams using New-PnPTeamsTeam #2977

Closed
harshdamaniahd opened this issue Apr 5, 2023 · 5 comments · Fixed by #3351
Closed

[BUG] - Unable to create teams using New-PnPTeamsTeam #2977

harshdamaniahd opened this issue Apr 5, 2023 · 5 comments · Fixed by #3351
Labels
bug Something isn't working

Comments

@harshdamaniahd
Copy link

harshdamaniahd commented Apr 5, 2023

Unable to create teams using New-PnPTeamsTeam. The pnp powershell version is 2.1.1
The Group is created, but the team never gets created.
When i user owner attribute , i get this error

New-PnPTeamsTeam: 
Line |
   5 |  $team = New-PnPTeamsTeam -DisplayName "write2" -Visibility Private  - …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Bad Request (400): /me request is only valid with delegated authentication flow.

I am using managed identity in azure runbook. Following permissions are given to managed identity
image

When i create the team locally , it works

here is the code in runbook


$connection = Connect-pnponline -managedidentity -url "https://test-admin.sharepoint.com" -returnconnection;
Write-Output $connection
try
{
$team = New-PnPTeamsTeam -DisplayName "write3" -Visibility Private  -connection $connection -Owners "[email protected]"
}
catch
{
    Write-Output $error
}


@harshdamaniahd harshdamaniahd added the bug Something isn't working label Apr 5, 2023
@gautamdsheth
Copy link
Collaborator

Looks like there is Graph API permissions changed, can you also please add TeamMember.ReadWrite.All application permission as well to the App and try ?

@harshdamaniahd
Copy link
Author

harshdamaniahd commented Apr 5, 2023

Looks like there is Graph API permissions changed, can you also please add TeamMember.ReadWrite.All application permission as well to the App and try ?
Yep i tried and same error
image

but this works with limited permission
image

$Group = New-PnPMicrosoft365Group -DisplayName "test14"-Isprivate -CreateTeam -MailnickName "test14" -Owners "[email protected]" -Description "myPnPDemo1-Description" -connection $connection

@veronicageek veronicageek changed the title [BUG] [BUG] - Unable to create teams using New-PnPTeamsTeam Apr 5, 2023
@gautamdsheth
Copy link
Collaborator

Ok that's strange, I got a specific error message asking me to add the TeamMember.ReadWrite.All permission.

In case of Managed identity, it sometimes takes quite a some time for the updated permissions to be reflected in the access token.

Thanks for letting us know, will close the issue now.

@harshdamaniahd
Copy link
Author

Ok that's strange, I got a specific error message asking me to add the TeamMember.ReadWrite.All permission.

In case of Managed identity, it sometimes takes quite a some time for the updated permissions to be reflected in the access token.

Thanks for letting us know, will close the issue now.

Unfortunately, I still get this error

New-PnPTeamsTeam: 
Line |
   5 |    $Team=New-PnPTeamsTeam -DisplayName "test24" -Visibility Private -c …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Bad Request (400): /me request is only valid with delegated authentication flow.

It only occurs when we user -Owners attribute,
$team = New-PnPTeamsTeam -DisplayName "write3" -Visibility Private -connection $connection -Owners "[email protected]"

@khha
Copy link

khha commented Jul 9, 2024

I have the same issue from an azure function under an managed identity.

  • When I try "New-PnPMicrosoft365Group" I got error "An error occurred while processing this request".
  • When I try "New-PnPTeamsTeam" I got the error "Bad Request (400): /me request is only valid with delegated authentication flow."

How to Teamify from an azure function under managed identity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants