Hi I'm migrating home drives from one of our legacy Domains to our new Domain. I have made a copy of the data to the new file server (Netapp) and am keeping the data in sync until we start cutting over users to use the new environment.
The problem I have is that the user accounts in the old environment don't match the user accounts in the new environment. In the old Domain the user accounts are first name followed by first initial of surname; whereas in the new environment accounts are the first name and surname of the user in full.
I have been provided a CSV file with the following information:
Old Domain Account Full Name Staff ID
Joe Bloggs (oldDomain\Joeb) Joe Bloggs 1234
John Smith (oldDomain\johns) John Smith 1235
I would like to use this information to do a powershell script to add the user accounts from the new domain for each user to their respective home drive folder.
I think the logic would go something like this:
1. each user home folder has the same name as the users account in the old domain.
2. for each user home folder, see if there is a match in the "old domain account" column of my CSV file.
3. if a match is found grant full control permissions to the user listed in the "full name" column, prefix'd with the name of my new domain (e.g. newDomain\Joe Bloggs)
4. finally rename users home folder to match their Staff ID.
So far all I've managed to do is read the names of the user home folders:
Get-ChildItem \\my file server\user_folders -Name -Attributes D
and read the "old domain account" column from the CSV file:
$sheetRead = Import-Csv -Path H:\Scripts\data_migration\Homedrive.csv | Select-Object "old domain accountt" | Out-String
Any help appreciated. Thanks.