Skip to main content

Set user home to path or local home

This PowerShell script streamlines the process of setting or updating home directory paths for multiple Active Directory (AD) users. It reads a list of usernames or User Principal Names (UPNs) from a file and uses the Set-ADUser cmdlet for the task. You can customize the home directory path or leave it empty to retain existing paths. Ideal for administrators managing users in a specific OU, the script enhances efficiency and maintains consistency within an AD environment.

# Get all AD users within the specified OU
$users = Get-Content -Path "<yourfilepathwithusernamesorupns>"

# Set the pathVariable or leave empty for local home path
$homePath = ""

# Loop through each user and check if the HomeDirectory property is not a local path
foreach ($user in $users) {
    Set-ADUser -Identity $user -HomeDirectory $homePath
}