I'm in the process of setting up a new server from a backup of a load of different websites. Copying across the backup has lost all the permissions for each file/folder, so I need to set the correct permissions. I know I can use icacls
to do this manually, but I figured it'd be quicker if I was able to run a script that finds all the app_data
folders on the new drive and recursively sets the file permissions for IIS_IUSRS
.
I'm not sure where to start on this. Can anyone help? TIA.
Options that come to mind:
s
option for security.Get/Set-Acl
. Anything beyond the most basic work usually had me resorting to .Net classes. Don't get me wrong, PowerShell's great at that, but for something as central to Windows as NTFS ACLs I always expected something more native. Ergo the NTFSSecurity Module. That said, in this case, where you simply want to copy an ACL it may be as simple as something like below:$ACLModel = Get-Acl -Path <SourceFolder>
Set-Acl -Path <DestFolder> -AclObject $ACLModel