Remove the Wiki tab!


As I understand, not that many use the wiki tab in Teams. Could be that I’m wrong. Anyway, her is a script that removes the Wiki tab from every channel in every team in your tenant.

#Application logon
# Azure AD OAuth Application Token for Graph API
# Get OAuth token for a AAD Application (returned as $token)
#Application (client) ID, tenant ID and secret
$clientId = "xxxx"
$tenantId = "xxxx"
$clientSecret = "xxxxx"
# Contruct URI
$uri = "$tenantId/oauth2/v2.0/token"
# Construct Body
$body1 = @{
client_id = $clientId
scope = ""
client_secret = $clientSecret
grant_type = "client_credentials"
# Get OAuth 2.0 Token
$tokenRequest = Invoke-WebRequest -Method Post -Uri $uri -ContentType "application/x-www-form-urlencoded" -Body $body1 -UseBasicParsing
$token = ($tokenRequest.Content | ConvertFrom-Json).access_token
$uri = ''
$query = Invoke-RestMethod -Method GET -Uri $uri -ContentType "application/json" -Headers @{Authorization = "Bearer $token"}
$groups = $query.value
foreach($group in $groups){
if($group.resourceProvisioningOptions -contains 'Team'){
$id = $
$uri2 = ''+$id+'/channels'
$query2 = Invoke-RestMethod -Method GET -Uri $uri2 -ContentType "application/json" -Headers @{Authorization = "Bearer $token"}
$Channels = $query2.value
Foreach($Channel in $Channels){
$id2 = $
$uri3 = ''+$id+'/channels/'+$id2+'/tabs'
$query3 = Invoke-RestMethod -Method GET -Uri $uri3 -ContentType "application/json" -Headers @{Authorization = "Bearer $token"}
$tabs = $query3.value
$WikiTabs = $tabs | Where-Object{$_.displayname -eq 'Wiki'}
Foreach($wikitab in $WikiTabs){
$wikitabID = $
$uri4 = ''+$id+'/channels/'+$id2+'/tabs/'+$wikitabID
$query4 = Invoke-RestMethod -Method DELETE -Uri $uri4 -ContentType "application/json" -Headers @{Authorization = "Bearer $token"}
"wikitab removed"
view raw RemoveWiki.ps1 hosted with ❤ by GitHub



7 thoughts on “Remove the Wiki tab!

  1. Which API permissions do I have to set?
    I always get

    Invoke-RestMethod : {
    “error”: {
    “code”: “Authorization_RequestDenied”,
    “message”: “Insufficient privileges to complete the operation.”,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s