{"id":762,"date":"2026-02-13T11:13:23","date_gmt":"2026-02-13T10:13:23","guid":{"rendered":"https:\/\/van-daag.nl\/?p=762"},"modified":"2026-02-13T11:13:23","modified_gmt":"2026-02-13T10:13:23","slug":"sharepoint-teams-rehydrate","status":"publish","type":"post","link":"https:\/\/van-daag.nl\/?p=762","title":{"rendered":"Sharepoint \/ Teams rehydrate"},"content":{"rendered":"\n<p>We had a customer what moved all file share data to a teams channel. after migration, not all files could be open om Teams. File extention is different, not attached to one specific app. Opening the files via Sharepoint was no issue. First issue what I tough was Onedrive or Teams reset. Did it, but was not solving. When I did that, I heared others have the same issue.<br>Next thing I tough about File length. but after checking, it was less than 400 characters.<\/p>\n\n\n\n<p><a href=\"https:\/\/support.microsoft.com\/en-us\/office\/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa\">Restrictions and limitations in OneDrive and SharePoint &#8211; Microsoft Support<\/a><\/p>\n\n\n\n<p>After some test, we found out that when download a file, delete the online file and place the file back with the same name, the file could be opened without issues. Looks like the Meta data of the file is corrupted.<\/p>\n\n\n\n<p>Ok. Now I have a solution, but how to do this with 50 GB of data and over 40.000 files to check.<br>Then found 2 ways, Connect the Sharepoint to a Onedrive. and do the local copy job. &#8220;Download&#8221; the files, Move it outside Sharepoint or on a new Sharepoint folder. But when you are doing this, there are some negative points.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Downloading and Uploading costs a lot of time<\/li>\n\n\n\n<li>Owner name \/ last modified name is changed.<\/li>\n\n\n\n<li>Version history is lost.<\/li>\n\n\n\n<li>Data is temporary not available.<\/li>\n<\/ul>\n\n\n\n<p>Based on the points above it was not the good way.<\/p>\n\n\n\n<p>The other way maybe better. A Powershell script that connects to Sharepoint online, and do a move internally in Sharepoint online. This is the best way to skip all the negative points above.<\/p>\n\n\n\n<p>Now its clear what to do, because I&#8217;m admin of the tenant but I don&#8217;t have a system in that tenant, and I don&#8217;t want to use my own system, I created a Hyper-V VM on my own system. <br>Installed the Default Windows 11 Image from Microsoft on the VM.<\/p>\n\n\n\n<p>Now I&#8217;m trying to sign in with a test account on that system. Mm, that&#8217;s not working. Found out that system is blocked by Intune policy (Enrollment restriction) that don&#8217;t allow Personally owned devices to add the the tenant.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" height=\"299\" width=\"640\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-1.png?resize=640%2C299&#038;ssl=1\" alt=\"\" class=\"wp-image-764\"\/><\/figure>\n\n\n\n<p>Example above.<\/p>\n\n\n\n<p>I created a new Enrollment restriction what is automatically placed above the default restriction. And add only personally owned to allow. <br>Added a new AAD group and add the test account in it. Added the AAD group to the new Enrollment restriction policy. Now waited 5 minutes and tried again. Finally signed in is working.<\/p>\n\n\n\n<p>Next step. Install PnP.PowerShell module.<\/p>\n\n\n\n<p>Start Powershell as Admin on the system. and type the following command to install the module.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Install-Module PnP.PowerShell -Scope CurrentUser -Force<\/code><\/pre>\n\n\n\n<p>When you get the message about NuGet update. Press <strong>Y<\/strong> and <strong>enter<\/strong>.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-3.png?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-766\"\/><\/figure>\n\n\n\n<p>Type <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Get-Module PnP.PowerShell -ListAvailable<\/code><\/pre>\n\n\n\n<p>You should get info about what module is installed.<br>On the default Windows 11 25h2 Powershell 5.1 is installed and wont give any output about the module that is installed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-4.png?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-767\"\/><\/figure>\n\n\n\n<p>Issue here is the PnP.Powershell module is working on minimal PowerShell 7.4.0.<br>So first we need to update Powershell to the latest. Easy way to update is trough Winget.<\/p>\n\n\n\n<p>Type in the current powershell window the following command to install the latest Powershell version<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">winget install --ID Microsoft.PowerShell --Source winget<\/code><\/pre>\n\n\n\n<p>Now is PowerShell Automatic installed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-5.png?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-768\"\/><\/figure>\n\n\n\n<p>Close current Powershell (5.1)<\/p>\n\n\n\n<p>Open the new Powershell 7 (x64) as Admin.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-6.png?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-769\"\/><\/figure>\n\n\n\n<p>Run the command <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Install-Module PnP.PowerShell -Scope CurrentUser -Force<\/code><\/pre>\n\n\n\n<p>And then to check if its installed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Get-Module PnP.PowerShell -ListAvailable<\/code><\/pre>\n\n\n\n<p>Result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-8.png?w=640&#038;ssl=1\" alt=\"\" class=\"wp-image-771\"\/><\/figure>\n\n\n\n<p>Now you need to connect to the Sharepoint tenant. Because all the security at Microsoft is higher than it was before. You cannot start connecting with username and password. Now you need to Register an Application with the correct rights to continue<\/p>\n\n\n\n<p>With the website <a href=\"https:\/\/www.sharepointdiary.com\/2018\/03\/connect-to-sharepoint-online-using-pnp-powershell.html\">Connect to SharePoint Online using PnP PowerShell &#8211; SharePoint Diary<\/a> I found the solution.<\/p>\n\n\n\n<p>The following code you need to enter in the Powershell 7 and edit the Tenantname:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Register-PnPEntraIDAppForInteractiveLogin -ApplicationName \"PnP PowerShell\" -SharePointDelegatePermissions \"AllSites.FullControl\" -Tenant Tenantname.onmicrosoft.com<\/code><\/pre>\n\n\n\n<p>Edge browser will automatic be opened Fill in the Admin username and password, and MFA. Then you get the message to close the browser.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" height=\"265\" width=\"640\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/Screenshot-2026-02-09-110236.png?resize=640%2C265&#038;ssl=1\" alt=\"\" class=\"wp-image-772\"\/><\/figure>\n\n\n\n<p>Powershell is still running, and after 30 seconds the browser opens again. You need to Sign in again. After that you need to accept the following window.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" height=\"417\" width=\"640\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-9.png?resize=640%2C417&#038;ssl=1\" alt=\"\" class=\"wp-image-773\"\/><\/figure>\n\n\n\n<p>Now the App is registered with the correct rights.<br>In the Powershell output, Save the ClientID for connecting to <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" height=\"89\" width=\"640\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/van-daag.nl\/wp-content\/uploads\/2026\/02\/image-10.png?resize=640%2C89&#038;ssl=1\" alt=\"\" class=\"wp-image-774\"\/><\/figure>\n\n\n\n<p>You can check if the connection is working with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Get-PnPWeb<\/code><\/pre>\n\n\n\n<p>Now we can connect to the Sharepoint with Powershell with the following code (Change &lt;TENANTNAME&gt; And &lt;SITENAME&gt;, and the CLIENTID.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">$SiteURL = \"https:\/\/&lt;TENNANTNAME&gt;.sharepoint.com\/sites\/&lt;SITENAME&gt;\"\nConnect-PnPOnline -Url $SiteURL -Interactive -ClientId \"&lt;CLIENTID&gt;\"<\/code><\/pre>\n\n\n\n<p>Now you can test a file if this fix the issue, You need to validate the locations because of language. Add\/Change location of the test file. (Code is generated by ChatGPT)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">$library    = \"Documenten\"\n$channel    = \"Algemeen\"\n$tempFolder = \"TempRehydrate\"\n$dryRun     = $True\n\n$testFile   = \"Gedeelde documenten\/General\/&lt;LOCATION OF A TEST FILE&gt;\"\n\nWrite-Host \"== Test 1 bestand ==\" -ForegroundColor Cyan\nWrite-Host \"Bestand:\" $testFile\nWrite-Host \"Dry-run:\" $dryRun\n\n# Temp folder maken (alleen echte run)\nif (-not $dryRun) {\n    Add-PnPFolder -Name $tempFolder -Folder \"$library\/$channel\" -ErrorAction SilentlyContinue\n}\n# Naar temp\n$targetUrl = $testFile -replace \"$library\/$channel\", \"$library\/$channel\/$tempFolder\"\n\nWrite-Host \"\u2192 Naar temp:\" $targetUrl\nif (-not $dryRun) {\n    Move-PnPFile -SourceUrl $testFile -TargetUrl $targetUrl -Force\n}\n\n# Terug\n$originalUrl = $targetUrl -replace \"$library\/$channel\/$tempFolder\", \"$library\/$channel\"\n\nWrite-Host \"\u2190 Terug:\" $originalUrlif \n(-not $dryRun) {\n    Move-PnPFile -SourceUrl $targetUrl -TargetUrl $originalUrl -Force\n}\n\nWrite-Host \"== Test klaar ==\" -ForegroundColor Green<\/code><\/pre>\n\n\n\n<p>If the Test is working, Change $dryRun = $False<br>Now it moves the file.<br>When I did this, somehow it updated the whole Sharepoint site, and all files was accessable trough Teams.<\/p>\n\n\n\n<p>I did some commands with <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">Get-PnPListItem -List \"Documenten\"<\/code><\/pre>\n\n\n\n<p>Because I could not get the correct directory. You can use this to browse in the sharepoint.<br>Add after Documenten\/&lt;Foldername&gt; to go in to a folder.<\/p>\n\n\n\n<p>When done, don&#8217;t forget to remove if you are done and not needed anymore.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enterprise Application (<a href=\"https:\/\/entra.microsoft.com\/#view\/Microsoft_AAD_IAM\/StartboardApplicationsMenuBlade\/~\/AppAppsPreview?Microsoft_AAD_IAM_legacyAADRedirect=true\">Link<\/a>)<\/li>\n\n\n\n<li>App registration (<a href=\"https:\/\/entra.microsoft.com\/#view\/Microsoft_AAD_RegisteredApps\/ApplicationsListBlade\/quickStartType~\/null\/sourceType\/Microsoft_AAD_IAM?Microsoft_AAD_IAM_legacyAADRedirect=true\">Link<\/a>) (check All Applications)<\/li>\n\n\n\n<li>Remove the created AAD group<\/li>\n\n\n\n<li>Remove the temp Enrollment restrictions (<a href=\"https:\/\/intune.microsoft.com\/?ref=AdminCenter#view\/Microsoft_Intune_Enrollment\/DeviceTypeRestrictions.ReactView\">Link<\/a>) if created<\/li>\n\n\n\n<li>Remove the Device (<a href=\"https:\/\/intune.microsoft.com\/?ref=AdminCenter#view\/Microsoft_Intune_DeviceSettings\/DevicesWindowsMenu\/~\/windowsDevices\">Link<\/a>)<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We had a customer what moved all file share data to a teams channel. after migration, not all files could be open om Teams. File extention is different, not attached to one specific app. Opening the files via Sharepoint was no issue. First issue what I tough was Onedrive or Teams reset. Did it, but [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[53,6,11,56],"tags":[],"class_list":["post-762","post","type-post","status-publish","format-standard","hentry","category-blogs","category-microsoft","category-powershell-script","category-windows-11"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=762"}],"version-history":[{"count":4,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/762\/revisions"}],"predecessor-version":[{"id":779,"href":"https:\/\/van-daag.nl\/index.php?rest_route=\/wp\/v2\/posts\/762\/revisions\/779"}],"wp:attachment":[{"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/van-daag.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}