12Knocksinna / Office365itpros

Office 365 for IT Pros PowerShell examples
MIT License
1.3k stars 570 forks source link

Remove-PostsTeamChannel.PS1 #116

Closed beigewell closed 1 month ago

beigewell commented 1 month ago

Additional API permission required on line 22 ChannelMessage.Read.All

Connect-MgGraph -NoWelcome -Scopes ChannelMessage.ReadWrite, Team.ReadBasic.All, TeamMember.Read.All, ChannelSettings.Read.All, ChannelMessage.Read.All

When running the script without -silentlycontinue shows this error

PS C:\temp> $ChannelMessages = Get-MgTeamChannelMessage -TeamId $Team.Id -ChannelId $SelectedChannel.Id -PageSize 50 -All Get-MgTeamChannelMessage : Missing scope permissions on the request. API requires one of 'ChannelMessage.Read.All'. Scopes on the request 'APIConnectors.Read.All, AuditLog.Read.All, ChannelMessage.ReadWrite, ChannelSettings.Read.All, Chat.Create, Chat.Read, Chat.ReadBasic, Chat.ReadWrite, ChatMessage.Read, ChatMessage.Send, Directory.AccessAsUser.All, Directory.Read.All, openid, Policy.Read.All, profile, RoleManagement.Read.Directory, Team.ReadBasic.All, TeamMember.Read.All, User.Read, User.Read.All, UserAuthenticationMethod.Read.All, email' Status: 403 (Forbidden)

12Knocksinna commented 1 month ago

Thanks. Will update the script

12Knocksinna commented 1 month ago

Actually, the script looks for ChannelMessage.ReadWrite, which is one of the scope permissions listed. Maybe your session didn't have this permission?

beigewell commented 1 month ago

it did have this permission as you can see above in the script output it lists I have Scopes on the request 'APIConnectors.Read.All, AuditLog.Read.All, ChannelMessage.ReadWrite, ChannelSettings.Read.All,

I admit it is weird as you would think that would give Read as well, but as soon as I added ChannelMessage.Read.All to the scope the error fixes itself

12Knocksinna commented 1 month ago

Another Graph mystery...