בזמנו כתבתי את זה להרשאות
זה פותח לו תקייה חדשה במיקום שאתה מספק לו בשם של היוזר ואז נותן הרשאה ופותח תיקיות משנההפכתי את זה לפונקצייה מסודרת... אבל אין לי את זה כרגע.. אם אתה לא מסתדר עם זה דבר איתי אני אחפש את הגמורה
$Path = "D:\powershell test\1"
$users = "test1","test2"
if ( -not ($Path.EndsWith("\"))){$Path = $Path+"\"}
foreach ($user in $users) {
$userpath = $Path+$user
New-Item –Type Directory -Force -Path $userpath
$acl = Get-Acl -Path $userpath
$acl.SetAccessRuleProtection($True, $False)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Administrators","FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("Users","Read", "ContainerInherit, ObjectInherit", "None", "Allow")
$acl.AddAccessRule($rule)
Set-Acl $userpath $acl
$folder = New-Item -ItemType directory -Force -Path ($userpath+"\"+"1")
$folder = New-Item -ItemType directory -Force -Path ($userpath+"\"+"2")
}