Creating a Home Drive with Windows PowerShell

With the following I will do 3 things:

1. Set the user his with drive letter
2. Create a on your home folders file share
3. Giving users full control on there folder.


The Script:

Get-ADUser -Filter * -SearchBase R0;OU=wardusers,DC=wardvissers,DC=local” | Foreach-Object {
$sam = $_.SamAccountName
$sid = $_.Sid

# Assign the Drive letter and Home Drive for the user in

SET-ADUSER $sam –HomeDrive $HomeDrive –HomeDirectory $HomeDir

# Create the on the root of the Users Share

NEW-ITEM –path $HomeDir -type directory -force


# Set parameters for Access rule

$dirACE=New-Object System..AccessControl.FileSystemAccessRule ($sid,$rights,$inheritance,$propagation,$allowdeny)
$dirACL=Get-Acl $HomeDir


Set-Acl -path $HomeDir -AclObject $dirACL

Write-Host $HomeDir access assigned


Translate »
%d bloggers like this: