Hi there,
please help me out with two maintenance tasks. I need 2 powershell scripts that based on a set of users, looks up the user's homefolder on our file server, then copies the contents to a new homefolder and deletes the old one.
Example Old home folder: <oldusername>
Example New home folder: <newusername>
The second task is to rename some home folders for a set of users. Where there current home folder exists rename it to a new name.
Hopefully someone out there that can assist.
Regards,
Ryan
for the copy job, you can use Move-Item, xcopy or robocopy, depending on how familiar you are with the respective command and what you need to do. robocopy is probably the most versatile and robust choice. It is part of the OS since Windows Vista.
Regarding the home drive, is this something you want to read from AD, or do you have a certain path scheme where you just need to fill in the user name?
Hi Tobias,
the homedrive parameter in AD is set as such at present "\\servername\users$\user logon name
I would like to rename this parameter as we are changing the naming convention of user logon names from firstname.surname to surname+first initial
eg: john.smith to smithj
hence i need to also rename the homedrive parameter, the also rename the actual folder.
Can you advise please
Hi,
I assume you want to edit the profile path property on the user ad object.
Get-ADUser
http://technet.microsoft.com/en-us/library/ee617241.aspx
Set-ADUser - to save the changes
http://technet.microsoft.com/en-us/library/ee617215.aspx
Get-ADUser | <modifications> | Set-ADUser is the way to go.
utilize split-path and join-path cmdlets to work with the path easily
split-path "\\servername\users$\user logon name" to get the "body"
split-path "\\servername\users$\user logon name" -leaf to get the user logon name
make sure you add some error handling and logging..
like>>
$userProfilePath = '\\servername\users$\John.Doe'$rootPath = Split-Path -Path $userProfilePath$userFolderName = Split-Path -Path $userProfilePath -Leaf$firstname, $surname = $userFolderName -split ".",2,"simplematch"
$userFolderName = ($firstname[0] + $surname).toLower()$userProfilePath = Join-Path -Path $rootPath -ChildPath $userFolderName$userProfilePathIf there is anything unclear in the script let me know, i will explain it further.
thank you for your advice and responding so promptly for my call out for help.
I am comfortable with the editing the Ad property path, but need some advice/assistance if you can to rename the folder name on the file server for each user that i edit the home folder profile path.
hope this makes sense.
thank you again
this should apply to you case
Assign a home folder to a domain user
http://support.microsoft.com/kb/816313
I suppose you rename the folders assign the correct permissions and bind them with the users and you are ready to go. but I am by no means an expert in user data migration.