Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell set owner for homefolders

$
0
0

Hi guys,

i've been tasked to set ownership on homefolders. users need to be owner of their homefolder.

i've found various script but they don't do what i want.

i try with the following script but it's not working. Could you help? (i'm sorry if my English or my code is bad, be kind :) i'm no it guy, just some "power" user) thx!!

The error with \\ in $homefolder is intended as i can't post links...

$domainName = "test.com"
$homefolder=" \ \ servername\homefolder$\user


foreach($folder in (Get-ChildItem $homefolder)) {


$username = $folder.Name
$acct = New-Object System.Security.Principal.NTAccount('$username')
$Folder.SetOwner($acct)
$folder.SetAccessControl($folder)

}


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>