I have attached a screenshot of the Custom PowerShell workflow used to create, attach, and apply permisions for a user and thier home directory when createing a new user in FIM.
Param($SamName,$SiteCode)
Import-Module ActiveDirectory
# Change these to work with FIM
#$SamName = $args[0]
#$SiteCode = $args[1]
$Spacer=" "
$SamName,$Spacer,$SiteCode | out-file -filepath c:\PSscripts\HomeDir.Log
#Set Home Directory Path
switch ($SiteCode)
{
SITE1 {$homedir = "\\HOMEDIRECTORYPATH\"+$SamName}
SITE2 {$homedir = "\\HOMEDIRECTORYPATH\"+$SamName}
SITE3 {$homedir = "\\HOMEDIRECTORYPATH\"+$SamName}
default {""}
}
if ($homedir){
#Create Home Directory
mkdir $homedir
#Assign Access Rights
$account="YOURDOMAINHERE\"+$SamName
$rights=[System.Security.AccessControl.FileSystemRights]::FullControl
$inheritance=[System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit"
$propagation=[System.Security.AccessControl.PropagationFlags]::None
$allowdeny=[System.Security.AccessControl.AccessControlType]::Allow
$dirACE=New-Object System.Security.AccessControl.FileSystemAccessRule ($account,$rights,$inheritance,$propagation,$allowdeny)
$dirACL=Get-Acl $homedir
$dirACL.AddAccessRule($dirACE)
Set-Acl $homedir $dirACL
#Assign AD Attributes
Set-ADUser -Identity $SamName -Replace @{homeDirectory=$homedir;homeDrive="H:"} -Confirm:$false -CannotChangePassword:$true
}
Return "Success"
Anthony Marsiglia