Solved

Script to change Home drive in AD User Properties

Posted on 2014-10-08
8
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insecure Windows Service Permissions in 2008 R2 Active Directory 6 53
Moving on from sbs 2008... 36 88
robocopy question 3 32
Time server on domain 3 25
Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
A procedure for exporting installed hotfix details of remote computers using powershell
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

730 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