Created
February 9, 2017 09:01
-
-
Save jonimattila/cbee64bbd6cdd91adbcb515e47df34b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import CSV file, commas as separators, headers are Path, Username | |
$Csv = Import-Csv C:\temp\file.csv | |
#Separate headers | |
foreach ($Line in $Csv) { | |
#Separate Path header for old user home folder | |
$UserHome_old = $Line.Path | |
#Separate Username header for new home folder location | |
$UserHome_new = "\\server\users1$\" + $Line.Username | |
$corpaccount = "DOMAIN\" + $Line.Username | |
#Robocopy switches, Backup mode, Copy Subdirs, Copy all file information, Write status output to console and log, Multithread 128, Verbose logging | |
$switches = ("/B", "/e", "/r:1", "/copyall", "/TEE", "/MT:128", "/V", "/log:C:\temp\$Line.Username.txt") | |
#Copy folder from old location to new location | |
& robocopy $UserHome_old $UserHome_new $switches | |
#Modify H: directory in AD | |
Set-ADuser -Identity $Line.Username -HomeDrive "H:" -HomeDirectory "$UserHome_new" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment