I am in the process of migrating all the data from one (1 TB) volume (not C:) on an AD server to a new 4 TB one. I have copied all the data including the FolderRedirection and Profile stuff.
I am just in the process of cloning the security ACL's with a little bit of PowerShell. Can anyone point me in the right direction on how to log the output to a file so i can review it and make sure nothing failed to write?
copypermissions.ps1
dir E:\Data -r | where {$_.PSIsContainer} | foreach {
$target= ($_.fullname).replace("E:","G:")
Get-Acl $_.Fullname | Set-Acl $target
}
Using the -whatif flag on the end of the Set-Acl command shows that it will try and do what i want it too but when i actually run it on a test folder not everything is copied and i get a couple of errors on the console looking like:
Set-Acl : The security identifier is not allowed to be the owner of this object.
At E:\copypermissions.ps1:3 char:32 + Get-Acl $_.Fullname | Set-Acl <<<< $target + CategoryInfo : InvalidOperation: (G:\Data\Profiles*USERNAME*:String) [Set-Acl], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetAclCommand
I am really looking for a simple 1 liner to add to the end of the script that will write any errors to a log file.