Ever had the situation, that a set of database files doesn't have the right permissions after a restore (maybe to another server) via. eg. Veeam? Powershell to the rescue!
$SOURCE = 'F:\SQLData\mydb.mdf' $DESTINATION = 'F:\SQLData\myrestoreddb.mdf' $PERMISSIONS = Get-Acl -Path $SOURCE Set-Acl -AclObject $PERMISSIONS -Path $DESTINATION
This will take the file permissions from your $SOURCE file and set them on your $DESTINATION file. Nice, easy, Powershell ;)