/ SCRIPTS

Package Exisiting User Profiles Into FSLogix VHDs In Bulk Using Powershell

If you’re upgrading your existing your current Virtual Desktop Infrastructure to include FSLogix for profile management, you’re most likely going to want to package your existing user profiles into VHD’s usable by FSLogix.

Thankfully as part of FSLogix there is a profile packaging utility called “frx.exe” which can be found under the FSLogix Apps install directory

(C:\Program Files\FSLogix\Apps\frx.exe by default)

The below script can be run on any VDI host to convert all of the profiles present under C:\users to FSLogix ready VHD’s

The script features and exclude list, so that you can exclude any unrequired profiles.

# Add NETBIOS usernames to this array to skip them from being packaged into VHDs
$excludedProfileFolders = @("Public", `
"administrator", `
"CompanyAdmin", `
"Helpdesk", `
"TaskScheduler"
)

# Set the below variable to your NETBIOS domain name
$domainNetBIOSName = "YOURDOMAIN"
# Set the path that you want to export the VHD's to - please do not end the path with a backslash
$ExportLocation = "F:\VHDExport\Profiles"

#Do not edit below here
$userfolders = gci C:\users | Where {($excludedProfileFolders -NotContains $_.Name)}

ForEach($profile in $userfolders){
    $objUser = New-Object System.Security.Principal.NTAccount($domainNetBIOSName, $profile.Name)
    $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) 

    If($strSID -ne $null){
            Write-Host "Running FSLogix Packaging for user $($profile)" -ForegroundColor Yellow
            Start-Process -FilePath "C:\Program Files\FSLogix\Apps\frx.exe" `
             -ArgumentList "copy-profile -filename=$($path)\$($profile)_$($strSID.Value).vhd -sid=$($strSID.Value) -dynamic=1 -label=PROFILE-$($profile)" `
             -Wait
    }
}