Im looking to add to an existing script for creating a new user to copy the clone user’s homedirectory I have everything working in the script so far but not sure where to start with copying the clone user home Directory.<\/p>\n
I can get it to work from CSV files when doing a mass creations but need to define the homedirectory first my clone user is $Clone and new user is $NewUser in my script can set the home drive with Set-ADUser $Newuser -HomeDrive $Clone.HomeDrive<\/p>\n
I need to copy $Clone:- \\homedrive\\UserDrive\\User1 and create $Newuser:- \\homedrive\\UserDrive\\User2 either with SamName or %Username%<\/p>","upvoteCount":9,"answerCount":5,"datePublished":"2021-07-27T01:39:04.000Z","author":{"@type":"Person","name":"davidchambers8111","url":"https://community.spiceworks.com/u/davidchambers8111"},"suggestedAnswer":[{"@type":"Answer","text":"
Im looking to add to an existing script for creating a new user to copy the clone user’s homedirectory I have everything working in the script so far but not sure where to start with copying the clone user home Directory.<\/p>\n
I can get it to work from CSV files when doing a mass creations but need to define the homedirectory first my clone user is $Clone and new user is $NewUser in my script can set the home drive with Set-ADUser $Newuser -HomeDrive $Clone.HomeDrive<\/p>\n
I need to copy $Clone:- \\homedrive\\UserDrive\\User1 and create $Newuser:- \\homedrive\\UserDrive\\User2 either with SamName or %Username%<\/p>","upvoteCount":9,"datePublished":"2021-07-27T01:39:04.000Z","url":"https://community.spiceworks.com/t/creating-new-user-with-personalised-home-drive/806662/1","author":{"@type":"Person","name":"davidchambers8111","url":"https://community.spiceworks.com/u/davidchambers8111"}},{"@type":"Answer","text":"
and where are you stuck with that?<\/p>\n
Have you looked into ‘copy-item’ and possibly the recurse switch?<\/p>\n
e.g.<\/p>\n
copy-item \"\\\\server\\share\\clone\" -destination \"\\\\server\\share\\$samaccountname\" -recurse\n<\/code><\/pre>\nrobocopy might do it it too? really depends on what exactly you need.<\/p>\n
Give it a try.<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n