Solved

Script to change Home drive in AD User Properties

Posted on 2014-10-08
8
280 Views
Last Modified: 2014-10-23
Does anyone have a script available to change the current Home drive to point to another server in AD User properties for everyone, please?
UserProperties2.jpg
0
Comment
Question by:Biertan
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40370054
hi,
There are hundreds of scripts on the internet depending on what you need to do.

I have also used this application http://www.wisesoft.co.uk/software/bulkadusers/default.aspx which allows forupdates from csv and excel file. It makes it easer to do updates for sets of staff without any scripting.

Steve
0
 

Author Comment

by:Biertan
ID: 40370181
hi Steven
I need to change the property to point to a new network share, via a powershell script if I can find one - directly manipulate the AD user property to change the Home Drive location.
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40370262
I would use a csv file with usernames with a get-content loop. with this command

http://blogs.technet.com/b/heyscriptingguy/archive/2013/06/04/creating-a-home-drive-with-windows-powershell-part-1.aspx

get-content c:\users.txt | SET-ADUSER % –HomeDrive ‘Z:’ –HomeDirectory ‘\\CONTOSO-FPS\Users$\%

that won't work but it's a start. I can supply full script if you like.  up to you
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:Biertan
ID: 40370331
I would really appreciate the full script, with many thanks.
0
 
LVL 12

Expert Comment

by:Steven Wells
ID: 40370349
Will have something to you tomorrow
0
 
LVL 17

Assisted Solution

by:Spike99
Spike99 earned 250 total points
ID: 40370546
how many users are you talking about?
If it's thousands, a script or a tool might be the best route.
But, if you don't have that many, the home directory is one of the few settings that can be edited on multiple users within AD:
1.  highlight a group of users
2.  right click & then click on properties
3.  click on the profile tab
4.  add the homedir path using the %username% variable
5.  Click Apply

So, it should look something like this:
Screenshot:  Editing properties for multiple AD accounts
AD will substitute the actual user name for each account in place of the %username% variable in that path.  You can try that out on 1 or 2 users to start off so you see how it works.

To speed things up, type the path into NotePad so you can copy/paste the path into that field for each group of users.

Selecting large groups of users as you go through each OU, you can edit that field for a lot of users pretty quickly, but it would be tedious if you have a ton of OUs to go through or thousands of users.

Otherwise, you might want to try ADModify to edit the home directory for your users.  ADModify also allows you to edit other fields in bulk which normally can't be edited on multiple objects in AD.  

You can download that here:
http://admodify.codeplex.com/

You can read more about the tool here:
http://blogs.technet.com/exchange/archive/2004/08/04/208045.aspx
0
 

Author Comment

by:Biertan
ID: 40370734
hi Alicia,


I have just under 900 users to change the attribute for.
Single OU.
0
 
LVL 12

Accepted Solution

by:
Steven Wells earned 250 total points
ID: 40371533
Hi

This script will loop through all staff within an OU as you have requested.

Import-Module ActiveDirectory

$ou = "OU=users,,Dc=trevandsteve,Dc=local"
$properties = "HomeDirectory", "HomeDrive" ,"l"

Get-ADUser -Filter * -SearchBase $ou -Properties $properties |

ForEach-Object {

 $sam = $_.SamAccountName
 $HomeDirectory = "\\fileserver\users$\$sam" 


 Set-ADUser $_.samaccountname -HomeDirectory $HomeDirectory -HomeDrive H
}

Open in new window


Adjust to your requirments for domian name and fileserver path

Run from powershell for ad

Otherwise I can get you a script that reads users from CSV file.

i also agree with Alica's comment about selecting all staff. Sometimes the simplest methods can be the best.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question