%3CLINGO-SUB%20id%3D%22lingo-sub-974304%22%20slang%3D%22en-US%22%3E(WAL)%20-%20Workflow%20Example%20-%20Create%20Home%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-974304%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Jan%2023%2C%202016%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20following%20Example%20is%20an%20illustration%20of%20how%20the%20PowerShell%20Workflow%20Activity%20could%20be%20used%2C%20some%20may%20argue%20that%20the%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fdn640417%2528v%3Dws.10%2529.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20PowerShell%20MA%20%3C%2FA%3E%20would%20be%20better%20suited%20for%20this%20type%20of%20activity%20and%20in%20a%20scenario%20where%20Bulk%20creations%20would%20be%20necessary%20i%20would%20agree%2C%20but%20this%20blog%20posting%20is%20to%20demonstrate%20that%20how%20to%20use%20the%20PowerShell%20Workflow%20Activity%20which%20is%20part%20of%20the%20%3CA%20href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fb%2Fconnector_space%2Farchive%2F2016%2F01%2F15%2Fthe-mimwal-custom-workflow-activity-library.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Workflow%20Activity%20Library%20%3C%2FA%3E%20.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20below%20example%20is%20a%20modified%20version%20of%20the%20previously%20documented%20%3CA%20href%3D%22http%3A%2F%2Fblogs.msdn.com%2Fb%2Fconnector_space%2Farchive%2F2014%2F10%2F01%2Fprovision-a-home-directory-for-new-accounts.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Post%20%3C%2FA%3E%20which%20was%20Documented%20using%20a%20Server%202008%20Target%20Domain%20Controller%20.%20The%20below%20example%20can%20be%20used%20with%20Server%202012%20R2%20or%20earlier.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdditionally%20its%20important%20to%20note%20that%20this%20workflow%20should%20be%20triggered%20after%20the%20Synchronization%20Service%20updates%20the%20users%20resourceSid%20(objectSid)%20in%20the%20FIM%20Portal%2C%20this%20would%20be%20a%20good%20indication%20that%20the%20user%20object%20has%20been%20created%20in%20AD.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20New%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EEnter%20the%20name%20for%20your%20Workflow%20(I%20start%20all%20my%20workflows%20with%20an%20%22_%22%20which%20makes%20it%20easy%20to%20identify%20all%20non%20custom%20workflows.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20Actions%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F153647i0DEF1B1C55B72E16%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20Next%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20WAL%3A%20Run%20PowerShell%20Script%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20Select%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EConfigure%20the%201st%20Workflow%20Activity%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EType%20in%20the%20name%20for%20the%20Activity%20that%20will%20be%20used%20as%20part%20of%20the%20Workflow%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3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%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EInclude%20in%20Workflow%20Definition%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EScript%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EParam(%24SamName%2C%24HomePath%2C%24DriveLet%2C%24Domian)%20%3CBR%20%2F%3E%23%23%20Create%20Remote%20Session%20(verify%20that%20the%20FIM%20Service%20account%20has%20permission%20to%20run%20Remote%20Powershell%20on%20the%20target%20DC)%20%3CBR%20%2F%3E%24Server%20%3D%20%22DC1%22%20%3CBR%20%2F%3E%24dc1%20%3D%20New-PSSession%20-ComputerName%20%24Server%20%3CBR%20%2F%3E%23%20Any%20errors%20during%20execution%20of%20the%20script%20or%20the%20script%20block%20are%20bubbled%20up%20automatically.%20%3CBR%20%2F%3E%23%20Comment%20out%20-ComputerName%20parameter%20when%20running%20interactively%20%3CBR%20%2F%3E%23%23%20Uncomment%20for%20Manual%20Testing%20%3CBR%20%2F%3E%23%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24SamName%20%3D%20%22orangejuice%22%20%3CBR%20%2F%3E%23%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24homepath%20%3D%20%22%5C%5CSvr2%5Ce%22%20%3CBR%20%2F%3E%23%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24DriveLet%3D%20%22H%22%20%3CBR%20%2F%3E%23%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24Domain%20%3D%20%22Contoso%22%20%3CBR%20%2F%3E%23%23Set%20Variables%20%3CBR%20%2F%3E%24Spacer%3D%20%22%20%22%20%3CBR%20%2F%3E%24HomeDir%20%3D%20%24homepath%20%2B%20%22%5C%22%20%2B%20%24SamName%20%3CBR%20%2F%3E%23%23%23%20%3CBR%20%2F%3E%23Create%20Home%20Directory%20%3CBR%20%2F%3Emkdir%20%24homedir%20%3CBR%20%2F%3E%23Assign%20Access%20Rights%20%3CBR%20%2F%3E%24account%3D%24Domain%2B%22%5C%22%2B%24SamName%20%3CBR%20%2F%3E%24rights%3D%5BSystem.Security.AccessControl.FileSystemRights%5D%3A%3AFullControl%20%3CBR%20%2F%3E%24inheritance%3D%5BSystem.Security.AccessControl.InheritanceFlags%5D%22ContainerInherit%2CObjectInherit%22%20%3CBR%20%2F%3E%24propagation%3D%5BSystem.Security.AccessControl.PropagationFlags%5D%3A%3ANone%20%3CBR%20%2F%3E%24allowdeny%3D%5BSystem.Security.AccessControl.AccessControlType%5D%3A%3AAllow%20%3CBR%20%2F%3E%24dirACE%3DNew-Object%20System.Security.AccessControl.FileSystemAccessRule%20(%24account%2C%24rights%2C%24inheritance%2C%24propagation%2C%24allowdeny)%20%3CBR%20%2F%3E%24dirACL%3DGet-Acl%20%24homedir%20%3CBR%20%2F%3E%24dirACL.AddAccessRule(%24dirACE)%20%3CBR%20%2F%3ESet-Acl%20%24homedir%20%24dirACL%20%3CBR%20%2F%3E%3CBR%20%2F%3E%23Assign%20AD%20Attributes%20%3CBR%20%2F%3E%23Enter-PSSession%20%24dc1%20%3CBR%20%2F%3EInvoke-Command%20-ComputerName%20%24Server%20-Script%20%7Bparam(%24SamName%2C%20%24HomeDir%2C%20%24DriveLet)%20Set-ADUser%20-Identity%20%24SamName%20-Replace%20%40%7BhomeDirectory%3D%24homedir%3BhomeDrive%3D%24DriveLet%7D%20-Confirm%3A%24false%7D%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3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EClick%20on%20Finish%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-974304%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Jan%2023%2C%202016%20The%20following%20Example%20is%20an%20illustration%20of%20how%20the%20PowerShell%20Workflow%20Activity%20could%20be%20used%2C%20some%20may%20argue%20that%20the%20PowerShell%20MA%20would%20be%20better%20suited%20for%20this%20type%20of%20activity%20and%20in%20a%20scenario%20where%20Bulk%20creations%20would%20be%20necessary%20i%20would%20agree%2C%20but%20this%20blog%20posting%20is%20to%20demonstrate%20that%20how%20to%20use%20the%20PowerShell%20Workflow%20Activity%20which%20is%20part%20of%20the%20Workflow%20Activity%20Library.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-974304%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAnthonyMarsiglia%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on MSDN on Jan 23, 2016

The following Example is an illustration of how the PowerShell Workflow Activity could be used, some may argue that the PowerShell MA would be better suited for this type of activity and in a scenario where Bulk creations would be necessary i would agree, but this blog posting is to demonstrate that how to use the PowerShell Workflow Activity which is part of the Workflow Activity Library .

 

The below example is a modified version of the previously documented Post which was Documented using a Server 2008 Target Domain Controller . The below example can be used with Server 2012 R2 or earlier.

 

Additionally its important to note that this workflow should be triggered after the Synchronization Service updates the users resourceSid (objectSid) in the FIM Portal, this would be a good indication that the user object has been created in AD.

 

 



    • Click on New





    • Enter the name for your Workflow (I start all my workflows with an "_" which makes it easy to identify all non custom workflows.

 

    • Select Actions





    • Click on Next

 

    • Select WAL: Run PowerShell Script



 

 

 




      • Click on Select



    • Configure the 1st Workflow Activity



      • Type in the name for the Activity that will be used as part of the Workflow



        • Activity Display Name



          • Create Home Directory



        • Advanced Features



          • false (Leave unchecked)



        • Script Location



          • Include in Workflow Definition



        • Script



          • Param($SamName,$HomePath,$DriveLet,$Domian)
            ## Create Remote Session (verify that the FIM Service account has permission to run Remote Powershell on the target DC)
            $Server = "DC1"
            $dc1 = New-PSSession -ComputerName $Server
            # Any errors during execution of the script or the script block are bubbled up automatically.
            # Comment out -ComputerName parameter when running interactively
            ## Uncomment for Manual Testing
            #     $SamName = "orangejuice"
            #     $homepath = "\\Svr2\e"
            #     $DriveLet= "H"
            #     $Domain = "Contoso"
            ##Set Variables
            $Spacer= " "
            $HomeDir = $homepath + "\" + $SamName
            ###
            #Create Home Directory
            mkdir $homedir
            #Assign Access Rights
            $account=$Domain+"\"+$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
            #Enter-PSSession $dc1
            Invoke-Command -ComputerName $Server -Script {param($SamName, $HomeDir, $DriveLet) Set-ADUser -Identity $SamName -Replace @{homeDirectory=$homedir;homeDrive=$DriveLet} -Confirm:$false} -Args $SamName, $HomeDir, $DriveLet



        • Input Type



          • Named Parameters



        • Named Parameters



          • Parameter 1



            • Parameter



              • SamName



            • Value Expression



              • [//Target/AccountName]




          • Parameter 2



            • Parameter



              • HomePath



            • Value Expression



              • "\\Svr2\e"




          • Parameter 3



            • Parameter



              • DriveLet



            • Value Expression



              • "H"




          • Parameter 4



            • Parameter



              • Domain



            • Value Expression



              • "Contoso"





        • Script Return Type



          • None





    • Click on Save



 

 

 

 

 

 

 



    • Click on Finish