These two PowerShell scripts work together to automate the process of migrating user profile data using the frx.exe tool. The first script, "New-FsLogixMigrationPrep.ps1", prepares the necessary input for the second script, "Start-FsLogixProfileMigration.ps1".
"New-FsLogixMigrationPrep.ps1": This script should be run on a domain controller that has access to both source and target storage accounts. It is responsible for generating a "migration_commands.txt" file that contains user names and their corresponding migration commands. The script retrieves all members of a specific Active Directory group, including users in nested groups. It then iterates through each user profile directory in the source file share, and if the user is a member of the specified group, it creates a corresponding directory in the target file share. The script also generates the frx.exe migration command for each user, depending on whether their profile is in VHD or VHDX format. Finally, the user names and migration commands are saved to the "migration_commands.txt" file.
"Start-FsLogixProfileMigration.ps1": This script should be run on one of the AVD session hosts. It reads the migration commands from the "migration_commands.txt" file generated by the first script. It processes each user migration sequentially, running the corresponding frx.exe command, and logs the output of each migration to a separate log file. The script ensures that only one user migration runs at a time, waiting for the completion of the current migration before starting the next one.
To run these scripts together: Save both scripts to your computer, naming them "New-FsLogixMigrationPrep.ps1" and "Start-FsLogixProfileMigration.ps1" respectively. Update the "New-FsLogixMigrationPrep.ps1" script with the appropriate source and target file share paths and the Active Directory group name. On a domain controller with access to both storage accounts, run "New-FsLogixMigrationPrep.ps1" in PowerShell with administrative privileges. This will generate the "migration_commands.txt" file in the "C:\temp" directory. Transfer the "migration_commands.txt" file to "C:\temp" directory on the AVD session host where the "Start-FsLogixProfileMigration.ps1" script is located. On the AVD session host, run "Start-FsLogixProfileMigration.ps1" in PowerShell with administrative privileges. This script will read the migration commands from the "migration_commands.txt" file, execute the migrations sequentially, and log the output to the "migration_log.txt" file in the "C:\temp" directory.