{"id":294740,"date":"2021-07-09T12:00:00","date_gmt":"2021-07-09T09:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-transfer-file-permissions-with-powershell-cloudsavvy-it\/"},"modified":"2021-07-09T12:00:00","modified_gmt":"2021-07-09T09:00:00","slug":"how-to-transfer-file-permissions-with-powershell-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-transfer-file-permissions-with-powershell-cloudsavvy-it\/","title":{"rendered":"#How to Transfer File Permissions with PowerShell \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2d21292070d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2d21292070d\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-transfer-file-permissions-with-powershell-cloudsavvy-it\/#Using_PowerShell_to_Transfer_Permissions\" >Using PowerShell to Transfer Permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-transfer-file-permissions-with-powershell-cloudsavvy-it\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Transfer File Permissions with PowerShell \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-4374\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/03\/23e4a5a4.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Powershell logo\" width=\"1400\" height=\"578\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Maintaining file share permissions across servers can be a major challenge but by using PowerShell, we can automate this process allowing you to go home early.<\/p>\n<p>When doing any file migration, you not only have to consider the files and folder themselves but also the permissions set on those objects. On each file and folder could potentially be a different set of Access Control Entries (ACEs) that make up an Access Control List (ACL). Depending on how many files you\u2019re migrating, this can be a lot.<\/p>\n<p>When moving files to a new location, the permissions don\u2019t always come with them. When doing a massive migration like entire file servers with intricate permissions in place, it\u2019s important to keep those permissions with the objects as they move to the new location.<\/p>\n<p>There are a few ways to do this.<\/p>\n<p>One favorite tool to perform file migrations is <em><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/adamtheautomator.com\/robocopy-the-ultimate\/\">robocopy<\/a><\/em>. <em>Robocopy<\/em> is a great tool with lots of bells and whistles, but it can be complicated to use and may not work in all situations. When this h<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ens, I\u2019ll usually look into a tool called <em><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/technet.microsoft.com\/en-us\/library\/cc753525(v=ws.11).aspx\">icacls<\/a><\/em>. This is a tool that\u2019s been around for a long time and, like <em>robocopy<\/em>, has a lot of switches, so let\u2019s simplify this tool a little bit with some PowerShell.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Using_PowerShell_to_Transfer_Permissions\"><\/span>Using PowerShell to Transfer Permissions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Although you can use the icacls command-line utility directly, it\u2019s not the easiest to understand. To remedy this, you\u2019re going to learn about a PowerShell as a wrapper to invoke the <em>icacls<\/em> tool to simplify this sometimes daunting process.<\/p>\n<p>First, we\u2019ll need to download an existing tool that\u2019s already created for us. One of the great things about the PowerShell community is that there\u2019s usually an existing tool out there to help us out. In this case, we\u2019re going to need a PowerShell module. This PowerShell module can be found in the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.powershellgallery.com\/\">PowerShell Gallery<\/a>.<\/p>\n<p>If you have PowerShell v4 or later, you\u2019ll already have some commands to grab this module quickly.<\/p>\n<pre><code>PS&gt; Find-Module -Name NTFSPermissionMigration | Install-Module&#13;\n<\/code><\/pre>\n<p>Once the code above is done, you should now have a new module installed on your computer available for use. Once this installation is done, we now need to run a command inside of the module against the folder containing all of the files we\u2019d like to transfer permissions on.<\/p>\n<pre><code>PS&gt; Save-Acl -FolderPath \\\\OLDSERVER\\FileShare -SaveFilePath C:\\FilePermissions.txt&#13;\n<\/code><\/pre>\n<p>Once this is run, you should see an output similar to this and begin to see that save file start to grow.<\/p>\n<pre><code>processed file: \\\\OLDSERVER\\FileShare\\File1.txt&#13;\nprocessed file: \\\\OLDSERVER\\FileShare\\File2.exe&#13;\nSuccessfully processed X files; Failed processing 0 files&#13;\n<\/code><\/pre>\n<p>When this is complete, you should now have all of the permissions for files and folders inside of the save file. Now, we can restore this file. Before this happens, though, be sure to do an <em>exact<\/em> copy of all the files inside of the old folder, otherwise this will not work.<\/p>\n<p>To restore the permissions to the new folder path, we\u2019d now use the <code>Restore-Acl<\/code> command.<\/p>\n<pre><code>PS&gt; Restore-Acl -RestoreToFolderPath \\\\NEWFILESERVER\\FileShare -PermissionFilePath C:\\FilePermissions.txt&#13;\nSuccessfully processed XXX files; Failed processing 0 files&#13;\n<\/code><\/pre>\n<p>Once this is complete, all NTFS permissions should be mirrored from your source folder and the new destination folder!<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Using a free community PowerShell module and a little bit of scripting magic can turn a daunting task of moving NTFS permissions from one server to another a piece of cake.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/4446\/how-to-transfer-file-permissions-with-powershell\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Transfer File Permissions with PowerShell \u2013 CloudSavvy IT&#8221; Maintaining file share permissions across servers can be a major challenge but by using PowerShell, we can automate this process allowing you to go home early. When doing any file migration, you not only have to consider the files and folder themselves but also the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":294741,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/03\/23e4a5a4.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-294740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/294740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=294740"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/294740\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/294741"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=294740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=294740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=294740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}