Powershell to copy File Owner from one file to another

I am trying to copy File & Folder Owner details from a duplicate folder structure (restored from a backup) to their original source folder structure after resetting permissions that required me to take ownership of every original

Using Get-ACL gives me the correct original owner
Get-ACL "$SFullPath" | Select-Object Owner
Owner
-----
ARCHITECTS\NCoates

I have tried using it in Set-ACL  but Powershell does not like this
$NewACL = Get-ACL "$SFullPath" | Select-Object Owner
Set-ACL "$TFullPath" $NewACL

I have also tried SetOwner but I think the format of Get-ACL "$SFullPath" | Select-Object Owner includes too much data
$OldOwner = Get-ACL "$SFullPath" | Select-Object Owner
$NewACL.SetOwner([System.Security.Principal.NTAccount] $OldOwner )

How do I correct the format of Get-ACL "$SFullPath" | Select-Object Owner to just show the user name?

Or is there a simpler way of using Powershell to do what I want?
ARamptonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott CSenior EngineerCommented:
It's not Powershell, but RoboCopy will do what you want.

http://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx

I think I may have found what you are looking for.  Take a look at this blog.

http://blogs.msdn.com/b/powershell/archive/2009/05/11/copy-acl.aspx
0
ARamptonAuthor Commented:
Sorry but I don't want to use RoboCopy

Copy-ACL does not seem to allow only copying Owner information
0
Prashant ShrivastavaConsultantCommented:
Restore the files backing up with directory folder permissions that will bring all permissions back as before.
0
ARamptonAuthor Commented:
Found a solution using | Format-Wide | Out-String and then .Trim()

I don't understand why getting correct PowerShell output in correct format seems so difficult

$SourceOwner = Get-ACL "$SFullPath" | Select-Object Owner | Format-Wide | Out-String
$SourceOwner = $SourceOwner.Trim()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.