Solved

Script to change Home drive in AD User Properties

Posted on 2014-10-08
8
268 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
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 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…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

911 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

19 Experts available now in Live!

Get 1:1 Help Now