• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Portal
    • Contact Support
    • Communities
    • Services
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Home Folder Move with User Moves
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • +JavaScript
    • -PowerShell
      • PowerShell Library Source Code
      • -PowerShell samples
        • Alert on pending approval request expiration
        • Building a Managed Unit Dynamically
        • Calculate user mailbox size
        • Checking the uniqueness of a property
        • Create Dynamic Group in PowerShell
        • Export Domain Users to a .csv file
        • Functions for creation of Policy links
        • Get Active Roles Management Shell Module version (with build number)
        • Home Folder Move with User Moves
        • How to schedule the Active Roles Management shell
        • Populating a custom Virtual Attribute with a readable accountExpires timestamp using an Active Roles Policy Script
        • PowerShell: Update Property Generation and Validation policy with a new possible value list
        • Random Password Generation
        • Renaming a user post-creation
        • Working with the mS-DS-ConsistencyGuid attribute
    • +VBScript

Home Folder Move with User Moves

Here is a Powershell script that can be used to have a user's Homedirectory change and move from one school location to another.

NOTES

Add this code as a Powershell Script Module. Then add it to your Policy as a "Script Execution Policy".

The "Parameters" tab will have two "Parameter values"

Add your Server name to the "Target Server"

Add your Shared folder name to the "Target Share"

The user's home folder will rename from what it is and then recreate itself on the new server when the user is moved using Active Roles.

SCRIPT

#*********************************************************************************

# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

#

# IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

# PLEASE CONTACT ONE IDENTITY PROFESSIONAL SERVICES.

#*********************************************************************************

 

function onInit($context)

{

$par1 = $Context.AddParameter("Target Server")

$par1.MultiValued = $False

$par1.Description = "LDAP Server"

$par2 = $Context.AddParameter("Target Share")

$par2.MultiValued = $False

$par2.Description = "Server Share"

$par2.Defaultvalue = "st_home$"

}

function onPreMove($Request)

{

$strOLDHomeDir = $DirObj.Get("homeDirectory")

Rename-Item "$strOLDHomeDir" "$strOLDHomeDir _MOVED"

}

function onPostMove($Request)

{

$strServer = [string]$PolicyEntry.Parameter("Target Server")

$strShare = [string]$PolicyEntry.Parameter("Target Share")

$strSamName = $DirObj.Get("samAccountName")

$folder = "\\$strServer\$strShare\$strSamName"

New-Item -ItemType Directory -Path "$folder"

New-Item -ItemType Directory -Path "$folder\Documents"

New-Item -ItemType Directory -Path "$folder\Favorites"

$permissions = Get-Acl $folder

$userpermissions = New-Object System.Security.AccessControl.FileSystemAccessRule($strSamName,“FullControl”, “ContainerInherit, ObjectInherit”, “None”, “Allow”)

$permissions.AddAccessRule($userpermissions)

Set-Acl $folder $permissions

Set-QADUser -identity "$strSamName" -homeDrive h: -homeDir "$folder"

}

#***** END OF CODE ***************************************************************

  • move user home folders
  • Script Center
  • Powershell
  • homedirectorys
  • Share
  • History
  • More
  • Cancel
Related
Recommended
  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center