Link to home
Create AccountLog in
Avatar of Mark_Mckie
Mark_Mckie

asked on

Script To move users home drive

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.
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

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.
Avatar of Mark_Mckie
Mark_Mckie

ASKER

That sounds interesting.

May i have a look?
$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

Will this copy the data from one server to the other?
no, it would just update the AD HomeDirectory property.
Do you know of any script to then move the data after it has changed the home drive path?
Or could this script be amended.
i'll modify the script no problem.
Thank you very much Sedgwick
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account