Link to home
Start Free TrialLog in
Avatar of Joseph Moody
Joseph MoodyFlag for United States of America

asked on

Set Owner recursively

I have been reading the Scripting Guy's post on setting file ownership for a specific user.

His code is:

$objUser = New-Object System.Security.Principal.NTAccount("fabrikam", "kenmyer")
$objFile = Get-Acl C:\Scripts\Test.txt
$objFile.SetOwner($objUser)
Set-Acl -aclobject $objFile -path C:\Scripts\Test.txt

Open in new window


This works great for a specific folder. I am trying to get it to work recursively so that all subfolders and files have the same specified owner.

How can this be done?
ASKER CERTIFIED SOLUTION
Avatar of Rajitha Chimmani
Rajitha Chimmani
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joseph Moody

ASKER

You are awesome!! Thank you.