Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Permissions - Take Ownership - Replace on subcontainers and objects

$
0
0

Hi,

I could use some help.

I have a script right now that works to grant ownership to the username of a directory in Profiles directory.

That part works fine, but I need to: Replace owner on subcontainers and objects

Could someone please assist? Thank you in advance.

 

$Users = Get-ChildItem -Path \\ServerName\Profiles\

Foreach ($User in $Users)
{
  $ACL = Get-ACL $User.PSPath
  $UserName = New-Object System.Security.Principal.NTAccount("DomainName", $User.name)
  $ACL.SetOwner($UserName)
  set-acl -Path $User.PSPath -aclObject $acl
  
}

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles