magnusbornes / Copy-MbTeamsWiki

Script that lets you copy a Wiki from one Team Channel to another.
The Unlicense
0 stars 0 forks source link

Unable to get ListId of source channel #1

Open JordanStopford opened 9 months ago

JordanStopford commented 9 months ago

Hi,

First off thanks for this script, hopefully will save people a lot of time! Unfortunately it's not working for us, it's failing on step 3:

$requestUri = $baseUri + "/sites/$($source.SiteId)/lists/?$filter=displayName eq '$($source.ChannelId)_wiki'&$select=id" Add-Member -InputObject $source -MemberType NoteProperty -Name 'ListId' -Value $((Invoke-MgGraphRequest -Uri $requestUri).Value.Id)

The request here is failing to populate the ListId parameter, but I'm not sure why. I'm not familiar with MS graph at all. Any help much appreciated!

JordanStopford commented 9 months ago

Hi just wanted to bump this one :)

magnusbornes commented 7 months ago

@JordanStopford I'm sorry I didn't see your Issue and comments earlier.

Hmm, there might be a bug when trying to copy a Wiki which is not the first Wiki that was created in that team. The data of the Wikis in Teams are stored in a List in the Site Contents of the connected SharePoint Site, and I think the list gets its name based on the channelId of the channel where the first Wiki is created in a Team.

However, the Wiki list is hidden in the GUI, so the easiest way to find it, is by using PowerShell or Graph.

Try editing the script and hardcode the List ID manually. If you are familiar with PnP.PowerShell, you should be able to fin the list Id by doing Get-PnPList, when connected to the source team's connected SharePoint Site.

Example: Connect-PnPOnline -Url "http://contoso.sharepoint.com/sites/sourcesite" Get-PnPList

Now look for the list that contains the wiki data. The DisplayName of the List should be a channel ID followed by "_wiki".

You want the Lists GUID (List ID), not the DisplayName. Put in the List ID after the "-Value" Property in step 3.

I haven't tested it, so I can't confirm that this is the issue, but it's worth a try.

Let me know how it goes!