backup and restore permissions
<p>I am currently using the following script to export the permissions, take ownership of a folder and then remove all permissions from that folder. The folder list is taken from a text file.</p>

<pre><code>$InputFile = "C:\temp\Folders.txt"
$OutputFile = "C:\temp\FolderPermissions.txt"
$FolderList = Get-Content $InputFile

foreach ($Folder in $FolderList) {
    Get-Acl $folder | Format-List &gt;&gt;$OutputFile

    $acl = Get-ACL -Path $folder
    $acl.SetAccessRuleProtection($True, $True)
    Set-Acl -Path $folder -AclObject $acl

    $ACL = Get-ACL -Path $Folder
    $Rules = $ACL.Access | Where-Object {$_.IdentityReference -notmatch 'Admin'}

    foreach ($Rule in $Rules) {
        [void]$ACL.RemoveAccessRule($Rule)
    }
    Set-Acl -Path $folder -AclObject $acl
}
</code></pre>

<p>I really want to be able to reverse this, but cannot figure out how to reapply the permissions from the file that it exports.</p>