Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

I am in the process of migrating all the data from one (1tb1 TB) volume (not cC:) on an AD server to a new 4tb4 TB one. I have copied all the data including the FolderRedirection and Profile stuff.

I am just in the process of cloning the Securtysecurity ACL's with a little bit of powershell, canPowerShell. 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

}

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

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.

Any ideas?

Regards Jon

I am in the process of migrating all the data from one (1tb) volume (not c:) on an AD server to a new 4tb one. I have copied all the data including the FolderRedirection and Profile stuff.

I am just in the process of cloning the Securty 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.

Any ideas?

Regards Jon

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.

Source Link
JTotham
  • 112
  • 8

Powershell - Cloning ACL's for whole drive - Error Log?

I am in the process of migrating all the data from one (1tb) volume (not c:) on an AD server to a new 4tb one. I have copied all the data including the FolderRedirection and Profile stuff.

I am just in the process of cloning the Securty 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.

Any ideas?

Regards Jon