Diese Tage war ich bei einem Kunden, um FSLogix zu implementieren. Für mich selbst war es das erste FSLogix Projekt. Deshalb habe ich als Unterstützung am ersten Tag, mein CTP Kollege René Bigler (@dready73) mitgenommen.
Ich habe dann basierend auf folgenden Vorlagen ein Script erstellt, um eine User Profile Disk (UPD) nach FSLogix Profile Disk zu migrieren.
- http://www.citrixirc.com/?p=848
- http://www.citrixirc.com/?p=857
Da ich von den beiden Quellen profitiert habe, möchte ich hier auch meine Variante teilen, da ich davon ausgehe, dass noch viele eine UPD nach FSLogix migrieren wollen.
Damit nicht alle Profile gleichzeitig migriert werden müssen, habe ich eine einfache Textdatei benutzt, in welcher die SAM Account Name’s stehen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
#Defining paths $UPDPath = '\\server1\upd$\Desktop' $NewProfilePath = '\\server1\fslogix$' $DiskProfileFolder = 'Profile' #Define the path to the user list and read it $UserListe = 'C:\temp\UserMigrate.txt' $Users = Get-Content $UserListe foreach ($U in $Users){ # User from the file corresponds to SAM $SAM = $U # Read SID based on SAM $SID = (New-Object System.Security.Principal.NTAccount($SAM)).translate([System.Security.Principal.SecurityIdentifier]).Value # Defining the path to the original UPD $UPD = Join-Path -Path $UPDPath -ChildPath ('UVHD-' + $SID + '.vhdx') Write-Output "Start with User: $SAM" If (Test-Path $UPD){ # If UPD file exists, define target path $FSLPath = Join-Path -Path $NewProfilePath -ChildPath ($SAM + '_' + $SID) # Create the destination folder If (!(Test-Path $FSLPath)){ Write-Output "Create Folder: $FSLPath" New-Item -Path $NewProfilePath -Name ($SAM + '_' + $SID) -ItemType Directory | Out-Null } # Set permissions from destination folder & icacls $FSLPath /setowner "$env:userdomain\$sam" /T /C | Out-Null & icacls $FSLPath /grant $env:userdomain\$sam`:`(OI`)`(CI`)F /T | Out-Null # Define destination file path $FSLDisk = Join-Path -Path $FSLPath -ChildPath ('Profile_' + $SAM + '.vhdx') # Copy profile disk to new destination Write-Output "Copy UPD: $UPD" Copy-Item -Path $UPD -Destination $FSLDisk | Out-Null # Mound Disk Image Mount-DiskImage -ImagePath $FSLDisk # Get drive letter $DriveLetter = (Get-DiskImage -ImagePath $FSLDisk | Get-Disk | Get-Partition).DriveLetter $MountPoint = ($DriveLetter + ':\') # Define path in the profile disk $DiskProfilePath = Join-Path -Path $MountPoint -ChildPath $DiskProfileFolder # Create path in the profile disk If (!(Test-Path $DiskProfilePath)){ Write-Output "Create Folder: $DiskProfilePath" New-Item $DiskProfilePath -ItemType Directory| Out-Null } # Defining the files and folders that should not be copied $Excludes = @("Profile","Uvhd-Binding","`$RECYCLE.BIN","System Volume Information") # Copy profile disk content to the new profile folder $Content = Get-ChildItem $MountPoint -Force ForEach ($C in $Content){ If ($Excludes -notcontains $C.Name){ Write-Output ('Move: ' + $C.FullName) Try { Move-Item $C.FullName -Destination $DiskProfilePath -Force -ErrorAction Stop } Catch { Write-Warning "Error: $_" } } } # Defining the registry file $regtext = "Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$SID] `"ProfileImagePath`"=`"C:\\Users\\$SAM`" `"Flags`"=dword:00000000 `"State`"=dword:00000000 `"ProfileLoadTimeLow`"=dword:00000000 `"ProfileLoadTimeHigh`"=dword:00000000 `"RefCount`"=dword:00000000 `"RunLogonScriptSync`"=dword:00000001 " # Create the folder and registry file Write-Output "Create Reg: $DiskProfilePath\AppData\Local\FSLogix\ProfileData.reg" if (!(Test-Path "$DiskProfilePath\AppData\Local\FSLogix")) { New-Item -Path "$DiskProfilePath\AppData\Local\FSLogix" -ItemType directory | Out-Null } if (!(Test-Path "$DiskProfilePath\AppData\Local\FSLogix\ProfileData.reg")) { $regtext | Out-File "$DiskProfilePath\AppData\Local\FSLogix\ProfileData.reg" -Encoding ascii } # Remove OST, sometimes there is an issue, so you can prevent. remove-item $DiskProfilePath\AppData\Local\Microsoft\Outlook\*.ost # Short delay and unmound the disk image Start-Sleep -Seconds 30 Dismount-DiskImage -ImagePath $FSLDisk } Write-Output "--------------------------------------------------------------------" } |