Solved

Script to change Home drive in AD User Properties

Posted on 2014-10-08
8
262 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
 

Author Comment

by:Biertan
ID: 40370331
I would really appreciate the full script, with many thanks.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now