{"id":3143,"date":"2019-06-12T17:07:39","date_gmt":"2019-06-12T16:07:39","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=3143"},"modified":"2019-06-12T17:07:39","modified_gmt":"2019-06-12T16:07:39","slug":"ultimate-folder-redirection-for-onedrive-teams-and-sharepoint","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2019\/06\/ultimate-folder-redirection-for-onedrive-teams-and-sharepoint\/","title":{"rendered":"Ultimate folder redirection for Onedrive, Teams and Sharepoint"},"content":{"rendered":"\n<p class=\"has-text-color wp-block-paragraph\" style=\"color:#fa0a0e\"><strong>Update: a more lightweight\/simpler version of this script is available<\/strong> <strong>here: <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2021\/09\/redirecting-anything-to-onedrive-for-business\/\">https:\/\/www.lieben.nu\/liebensraum\/2021\/09\/redirecting-anything-to-onedrive-for-business\/<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the post-Onedrivemapper era where we have Files On Demand, there is still room for improvement in client side configuration of Onedrive for Business. Onedrive Known Folders isn&#8217;t up to par yet, doesn&#8217;t support any customization and there are situations where I want to be able to redirect local folders to other places than Onedrive like Teams or Sharepoint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore I present to you &#8220;<a rel=\"noreferrer noopener\" aria-label=\"Invoke-O4BAutoMount (opens in a new tab)\" href=\"https:\/\/gitlab.com\/Lieben\/assortedFunctions\/blob\/master\/Invoke-O4BAutoMount.ps1\" target=\"_blank\">Invoke-O4BAutoMount<\/a>&#8220;; the <span style=\"text-decoration: underline;\">ultimate<\/span> Onedrive\/Sharepoint\/Teams sync and redirect solution in modern workplace scenario&#8217;s, no WebDav, just the NSG Onedrive Client and native Intune Management Extension:<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"228\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_31_07-Presentation1-PowerPoint.png\" alt=\"\" class=\"wp-image-3144\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_31_07-Presentation1-PowerPoint.png 638w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_31_07-Presentation1-PowerPoint-300x107.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>Single PS script<\/li><li>User does NOT have to be an Admin<\/li><li>Per special folder configuration of redirection settings<\/li><li>Extra (symlink) redirection for <strong>ANY<\/strong> folder (specific appdata subfolders anyone?)<\/li><li>Automatically runs at logon and\/or at specified intervals<\/li><li>Can be unassigned (removing a user from the target group in Intune stops the script from running)<\/li><li>Can redirect to subfolders, even nested<\/li><li>Handles automatic creation of any folders<\/li><li>Supports variables in paths<\/li><li>Registers Environment Variables for the new locations if you configure it to<\/li><li>Can hide target folders (appdata likes to hide)<\/li><li>Multi-user support (Windows Virtual Desktop \/ Server 2019)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to use in 8 easy steps:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Configure the <a rel=\"noreferrer noopener\" aria-label=\"tenant ID (opens in a new tab)\" href=\"https:\/\/gitlab.com\/Lieben\/assortedFunctions\/blob\/master\/get-tenantIdFromLogin.ps1\" target=\"_blank\">tenant ID<\/a> and how often you want to script to run:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"56\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_46_52-Windows-PowerShell-ISE.png\" alt=\"\" class=\"wp-image-3152\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_46_52-Windows-PowerShell-ISE.png 486w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_46_52-Windows-PowerShell-ISE-300x35.png 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2. Then get the ODOpen URL of any libraries you wish to sync:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"470\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/get-odopen-url.png\" alt=\"\" class=\"wp-image-3145\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/get-odopen-url.png 890w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/get-odopen-url-300x158.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/get-odopen-url-768x406.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><figcaption>Use Chrome or Edge, <span style=\"text-decoration: underline;\">do not use Internet Explorer!<\/span><br>Edit: some users report that this link is gone, check the script source for a workaround \ud83d\ude42<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. paste the URL into the script in the syncUrl section and configure the site and list titles:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"111\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_18_31-Windows-PowerShell-ISE.png\" alt=\"\" class=\"wp-image-3166\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_18_31-Windows-PowerShell-ISE.png 924w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_18_31-Windows-PowerShell-ISE-300x36.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_18_31-Windows-PowerShell-ISE-768x92.png 768w\" sizes=\"auto, (max-width: 924px) 100vw, 924px\" \/><figcaption>User experience: The site and list title will show in explorer like &#8220;siteTitle &#8211; listTitle&#8221;<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4. if you only need Onedrive and don&#8217;t want to sync any sharepoint\/teams libraries, configure like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"361\" height=\"75\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_40_11-Windows-PowerShell-ISE.png\" alt=\"\" class=\"wp-image-3148\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_40_11-Windows-PowerShell-ISE.png 361w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_40_11-Windows-PowerShell-ISE-300x62.png 300w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">5. Pick which folders you want to redirect, and where you want to redirect them to:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1703\" height=\"333\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE.png\" alt=\"\" class=\"wp-image-3167\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE.png 1703w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE-300x59.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE-1024x200.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE-768x150.png 768w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-13-15_20_22-Windows-PowerShell-ISE-1536x300.png 1536w\" sizes=\"auto, (max-width: 1703px) 100vw, 1703px\" \/><\/a><figcaption> <em>This example redirects the My Documents and Desktop folders to the user&#8217;s Onedrive, and the Pictures folder to a subfolder in a teamsite called &#8220;AutoMapTestTeam&#8221;, the subfolder is automatically created using the user&#8217;s email address<\/em>.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6. Configure any special folders that normally cannot be redirected<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1462\" height=\"68\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE.png\" alt=\"\" class=\"wp-image-3150\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE.png 1462w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE-300x14.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE-1024x48.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_41_47-Windows-PowerShell-ISE-768x36.png 768w\" sizes=\"auto, (max-width: 1462px) 100vw, 1462px\" \/><\/a><figcaption>This example will redirect the local  Skype folderin APPDATA to a user&#8217;s Onedrive, thus roaming Skype contacts and profile information to Onedrive<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">7. Upload to Intune as a PowerShell script:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_44_56-Script-Settings-Microsoft-Azure.png\"><img loading=\"lazy\" decoding=\"async\" width=\"931\" height=\"474\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_44_56-Script-Settings-Microsoft-Azure.png\" alt=\"\" class=\"wp-image-3151\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_44_56-Script-Settings-Microsoft-Azure.png 931w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_44_56-Script-Settings-Microsoft-Azure-300x153.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2019\/06\/2019-06-12-17_44_56-Script-Settings-Microsoft-Azure-768x391.png 768w\" sizes=\"auto, (max-width: 931px) 100vw, 931px\" \/><\/a><figcaption>Make sure you set it to 64 bit AND to <span style=\"text-decoration: underline;\">run as system<\/span> instead of the user&#8217;s logged on credentials<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">8. Deploy to your <span style=\"text-decoration: underline;\">users<\/span><strong> <\/strong>(you can also deploy to machines, but then you need to set autoRerunMinutes to &gt; 0 and it might not run at logon)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Further recommendations<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This script assumes you&#8217;ve already <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2019\/06\/onedrive-admx-recommendations\/\">Configured Onedrive to automatically log the user in<\/a> and I strongly recommend to <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2019\/06\/moving-to-onedrive-per-machine-mode-in-intune\/\">run Onedrive in Per Machine Mode for faster config<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I haven&#8217;t extensively tested running this script when multiple users are active on a device <strong>at the same time<\/strong> (ie: citrix, wvd, remoteapp); I&#8217;d love to hear about your results!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Thanks and inspiration<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.iphase.dk\/\" target=\"_blank\">Michael Mardahl<\/a> for giving me the ODOPEN and IME hack examples<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" aria-label=\"Aaron Parker (opens in a new tab)\" href=\"https:\/\/stealthpuppy.com\/\" target=\"_blank\">Aaron Parker<\/a> for writing on Folder Redirection with PowerShell<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" aria-label=\"Justin Murray (opens in a new tab)\" href=\"https:\/\/www.linkedin.com\/in\/justin-murray-02291242\/\" target=\"_blank\">Justin Murray<\/a> for showing me how to impersonate another user<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" aria-label=\"Per Larsen (opens in a new tab)\" href=\"https:\/\/osddeployment.dk\/about\/\" target=\"_blank\">Per Larsen<\/a> for writing on silent config \/ admx stuff regarding Onedrive<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a rel=\"noreferrer noopener\" aria-label=\"Olivier Kieselbach (opens in a new tab)\" href=\"https:\/\/oliverkieselbach.com\/\" target=\"_blank\">Olivier Kieselbach<\/a> for his three deep dives on the Intune Management Extension<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Lightweight version<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2021\/9: I&#8217;ve added  a more lightweight version that supports redirection only (with custom PS commands supported). The redirections have to be configured through the registry, see <a href=\"https:\/\/gitlab.com\/Lieben\/assortedFunctions\/-\/blob\/master\/Invoke-O4BAutoMount_v2.ps1\" target=\"_blank\" rel=\"noreferrer noopener\">the code here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Notice<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As always, this is a free script and no guarantees are given, use at your own risk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Troubleshooting<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Log locations:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> c:\\\\users\\\\appdata\\\\local\\\\temp\\\\Invoke-O4BAutoMount.log for the user portion. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C:\\\\Windows\\\\Temp\\\\Invoke-O4BAutoMount.log for the SYSTEM portion <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the script isn&#8217;t running at all (no log file), check the HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\IntuneManagementExtension\\Policies subkeys for error info from the script. Make sure the config section of the script is correct or it won&#8217;t run.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If it isn&#8217;t as running as frequently as you like, you may be getting throttled. Don&#8217;t run more frequently than hourly (per account).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also check <a href=\"https:\/\/oliverkieselbach.com\/2018\/02\/12\/part-2-deep-dive-microsoft-intune-management-extension-powershell-scripts\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Olivier's deep dives for general troubleshooting of Powershell scripts with Intune (opens in a new tab)\">Olivier&#8217;s deep dives for general troubleshooting of Powershell scripts with Intune<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: a more lightweight\/simpler version of this script is available here: https:\/\/www.lieben.nu\/liebensraum\/2021\/09\/redirecting-anything-to-onedrive-for-business\/ In the post-Onedrivemapper era where we have Files On Demand, there is still room for improvement in client side configuration of Onedrive for Business. Onedrive Known Folders isn&#8217;t up to par yet, doesn&#8217;t support any customization and there are situations where I want &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2019\/06\/ultimate-folder-redirection-for-onedrive-teams-and-sharepoint\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Ultimate folder redirection for Onedrive, Teams and Sharepoint<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[4,12,22,32,34,39,44],"tags":[],"class_list":["post-3143","post","type-post","status-publish","format-standard","hentry","category-automation","category-ems","category-intune","category-office-365","category-onedrive-for-business","category-powershell","category-sharepoint-online"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=3143"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3143\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=3143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=3143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=3143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}