Quantcast
Channel: Forum Microsoft Identity Manager
Viewing all articles
Browse latest Browse all 6944

Home Directory Custom PowerShell Workflow

$
0
0

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

Viewing all articles
Browse latest Browse all 6944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>