Advertisement
Guest User

student profile reset

a guest
Aug 30th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. $userName=Read-Host "Please enter a Username"
  2. $Directory = "\\alfriston\users\Profile\Students\$userName"
  3. Rename-Item -path $Directory -newName "$userName old"
  4. New-Item -Path $Directory -Type directory
  5. $acl = Get-Acl -Path $Directory
  6. $perm = $userName, 'Read,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
  7. $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
  8. $acl.SetAccessRule($rule)
  9. $acl | Set-Acl -Path $Directory
  10. $DirectoryV2 = "\\alfriston\users\Profile\Students\$userName.V2"
  11. Rename-Item -path $DirectoryV2 -newName "$userName.V2 old"
  12. New-Item -Path $DirectoryV2 -Type directory
  13. $acl = Get-Acl -Path $DirectoryV2
  14. $perm = $userName, 'Read,Modify', 'ContainerInherit, ObjectInherit', 'None', 'Allow'
  15. $rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $perm
  16. $acl.SetAccessRule($rule)
  17. $acl | Set-Acl -Path $DirectoryV2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement