As Technet Gallery is retiring so moving the code to Git Hub. (click below github download link for this script)
Backup and Restore permissions – Powershell
This Script/Process is all about backing up permissions & restoring when required.
This was the requirement from one of the projects, as their backup software was not able to take permissions backup,
therefore on restoring permissions were not getting applied.
Thanks to Powershell & Creator of File System Security PowerShell Module 4.0.1 which has come to our rescue 🙂
Here is the process /scripts that will accomplish this task, Download the zip file & extract it.
Tech Wizard
Hi,
First I want to thank you for this script. I am new and looking for script to backup and restore folder permissions, for the file share migration.
Can you help me with the error I got when trying to run this script?
Add-Type : Could not load file or assembly ‘file:///C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work
Files\Script\Backup-RestorePerm\NTFSSecurity\Security2.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work Files\Script\Backup-RestorePerm\NTFSSecurity\NTFSSecurity.Init.ps1:76 char:1
+ Add-Type -Path $PSScriptRoot\Security2.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Could not load file or assembly ‘file:///C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work
Files\Script\Backup-RestorePerm\NTFSSecurity\PrivilegeControl.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work Files\Script\Backup-RestorePerm\NTFSSecurity\NTFSSecurity.Init.ps1:77 char:1
+ Add-Type -Path $PSScriptRoot\PrivilegeControl.dll -ReferencedAssembli …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Could not load file or assembly ‘file:///C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work
Files\Script\Backup-RestorePerm\NTFSSecurity\ProcessPrivileges.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work Files\Script\Backup-RestorePerm\NTFSSecurity\NTFSSecurity.Init.ps1:78 char:1
+ Add-Type -Path $PSScriptRoot\ProcessPrivileges.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
**********************
Windows PowerShell transcript start
Start time: 20200518112326
Username: ANYACCESS\rcadlawon-sa
RunAs User: ANYACCESS\rcadlawon-sa
Configuration Name:
Machine: PHISBWKS19P7Y (Microsoft Windows NT 10.0.18362.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Process ID: 2028
PSVersion: 5.1.18362.752
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18362.752
BuildVersion: 10.0.18362.752
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is .\logs\backup_5-18-2020_11-23AM_.log
Processing ………\\NewORGFS\NewORGFS$
get-ntfsaccess : The term ‘get-ntfsaccess’ is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work Files\Script\Backup-RestorePerm\BackupPerm.ps1:43
char:30
+ get-childitem $_ -recurse | get-ntfsaccess -excludeinherited | expor …
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-ntfsaccess:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
get-ntfsaccess : The term ‘get-ntfsaccess’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\RMC\PASAR Working Files\GLENCORE Migration\FILESHARE Work Files\Script\Backup-RestorePerm\BackupPerm.ps1:43 char:30
+ get-childitem $_ -recurse | get-ntfsaccess -excludeinherited | expor …
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (get-ntfsaccess:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
**********************
Windows PowerShell transcript end
End time: 20200518112326
**********************
You need to install the File System Security PowerShell Module 4.0.1 first before execution of the script or download the whole zip folder and extract it, it has the module.