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
Solved

Script To move users home drive

Posted on 2013-05-13
11
328 Views
Last Modified: 2013-05-14
Hi there i am looking for a tool/script to be able to run from  my workstation to be able to move a users home drive from one server to another.

So say their home drive was \\server1\homes\user1

I could type the users name in and it would show me that it is currently on server1 and then offer me a drop down list that i could select server2 server3 etc and then click a move button.

it would then update their AD with the new location and then move the data.

Any help would be appreciated.
0
Comment
Question by:Mark_Mckie
  • 6
  • 5
11 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39161575
i can give u a script which prompt u for user name, show u current hoe drive and allow u to change it (no drop down) by entering new server.
and it would be in powershell.
0
 

Author Comment

by:Mark_Mckie
ID: 39161584
That sounds interesting.

May i have a look?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39161690
$name = Read-Host 'Enter user SamAccountName: (x to Abort)'
if($name -eq 'x'){return}
$user = (Get-ADUser -Filter {SamAccountName -eq $name}  | select 'HomeDirectory')
$msg = [string]::Format("Current home Dir [{1}], {2}", $user.HomeDrive, $user.HomeDirectory, "Enter new home dir: (x to Abort)") 
Read-Host $msg
if($msg -eq 'x'){return}
Set-ADUser $name -HomeDirectory $msg

Open in new window

0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:Mark_Mckie
ID: 39163808
Will this copy the data from one server to the other?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39163816
no, it would just update the AD HomeDirectory property.
0
 

Author Comment

by:Mark_Mckie
ID: 39163828
Do you know of any script to then move the data after it has changed the home drive path?
0
 

Author Comment

by:Mark_Mckie
ID: 39163829
Or could this script be amended.
0
 

Author Comment

by:Mark_Mckie
ID: 39163836
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 39163867
i'll modify the script no problem.
0
 

Author Comment

by:Mark_Mckie
ID: 39163887
Thank you very much Sedgwick
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39163904
here's the full script:
$name = Read-Host 'Enter user SamAccountName: (x to Abort)'
if($name -eq 'x'){return}
$user = (Get-ADUser -Filter {SamAccountName -eq $name}  | select 'HomeDirectory')
$homedir = [string]::Format("Current home Dir [{1}], {2}", $user.HomeDrive, $user.HomeDirectory, "Enter new home dir: (x to Abort)") 
Read-Host $homedir
if($homedir -eq 'x'){return}
write-output "Set$name HomeDirectory as $homedir"
Set-ADUser $name -HomeDirectory $homedir
write-output "Done"
$src = $user.HomeDrive
$dest = $homedir
write-output "copy $src to $dest"
gci $src -Recurse | Copy-Item -Destination $dest
write-output "Done"

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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