Solved

Script to change Home drive in AD User Properties

Posted on 2014-10-08
8
272 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

786 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