Skip to content

Commit

Permalink
Create Change Home Directory Permissions (All Users).ps1
Browse files Browse the repository at this point in the history
Requires the AD module from RSAT installed/enabled and the NTFSSecurity module from here: https://ntfssecurity.codeplex.com/
  • Loading branch information
cosine83 authored Jun 17, 2016
1 parent 0e3d1c5 commit 36aa22c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Change Home Directory Permissions (All Users).ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Import-Module ActiveDirectory
Import-Module NTFSSecurity

$query = Get-ADUser -Filter {Enabled -eq $true} | Sort SamAccountName
$users = $query.SamAccountName
$Admin = "BUILTIN\Administrators"
$Dadmins = "DOMAIN\Domain Admins"
$Sys = "NT AUTHORITY\SYSTEM"

foreach ($user in $users) {
$userH = Get-ADUser $user -Properties HomeDirectory
$HDrive = $userH.HomeDirectory
Set-NTFSOwner -Path $HDrive -Account $Admin
Disable-NTFSAccessInheritance -Path $HDrive -RemoveInheritedAccessRules
Get-NTFSAccess -Path $HDrive | Remove-NTFSAccess
Add-NTFSAccess -Path $HDrive -Account PEPPERMILLCAS\$user, $Admin, $Dadmins, $Sys -AccessRights FullControl
Write-Host -Foreground Yellow -Background Black "Changed H drive permissions for $user"
}

0 comments on commit 36aa22c

Please sign in to comment.