Set homeDirectory attribute to users from input csv file

The non-standard home directory path will be set on the user account in active directory using the input file called home-dir-path.csv which contains two fields.

The Microsoft Logon name, the samAccount attribute, followed by the Home Directory Path in UNC format, which is the homeDirectory attribute.

The tool used to set the attribute is Quest powershell with the Set-QADUser

For a single user, it would be executed as such:

Set-QADUser b125013 -HomeDirectory \\server\vol1\user\b125013

I made a script called SetHomeDir.ps1, that has the following code

Import-Csv home-dir-path.csv | ForEach-Object {

Set-QADUser $_.SamAccountName –HomeDirectory $_.HomeDirectory

}

Make sure the input csv file has the following line for the first row:

SamAccountName, HomeDirectory

Advertisements

About Mike

owner of blog
This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s