Wondering if anyone in this forum can help me figure out what I am doing wrong with my script. I am grabbing a text file with a list of users in it. I want to then create folders for all those people and then set explicit permissions on those folders to only allow the users and admin access to it. So for the create user folder, I have...
$Users = Get-Content "C:\Users.txt"
ForEach ($user in $users)
$newPath = Join-Path \\mycomputer\Users
$ -childpath $user
New-Item $newPath -type directory
This works great as I now have 100 folders created. But how do I use something like....
$acl = Get-Acl "\\mycomputer\users$
$permission = "mydomain\$users","FullControl","Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl | Set-Acl \\mycomputer\users$\$user
When I try to loop these together it says the folder already exists or the setaccessrule identity references could not be translated.
Anyone know how I loop it in with creating the folder? Or is there a way to just say...create folder based on this username, then take that username and make it the only admin on the folder along with the system admin??