Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $userName=Read-Host "Please enter a Username"
- $Directory = "\\alfriston\users\Profile\Students\$userName"
- Rename-Item -path $Directory -newName "$userName old"
- New-Item -Path $Directory -Type directory
- $acl = Get-Acl -Path $Directory
- $perm = $userName, 'Read,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
- $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
- $acl.SetAccessRule($rule)
- $acl | Set-Acl -Path $Directory
- $DirectoryV2 = "\\alfriston\users\Profile\Students\$userName.V2"
- Rename-Item -path $DirectoryV2 -newName "$userName.V2 old"
- New-Item -Path $DirectoryV2 -Type directory
- $acl = Get-Acl -Path $DirectoryV2
- $perm = $userName, 'Read,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
- $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
- $acl.SetAccessRule($rule)
- $acl | Set-Acl -Path $DirectoryV2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement