functions/Convert-CFXUser.ps1
function Convert-CFXUser { [CmdletBinding()] param ( # Username used for logon (SAMAccountName) [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] [string[]] $Username, # Location of Citrix Profile for all users e.g. \\FileServer\CitrixProfiles\ [Parameter(Mandatory = $true)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string] $CitrixProfileRootFolderPath, # Location of Citrix Profile for all users e.g. \\FileServer\RedirectedFolders\ [Parameter(Mandatory = $true)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string] $RedirectedFoldersRootPath, # Location of FSLogix Profile e.g. \\FileServer\FSLogixProfileContainers\ - accepts multiple entries. [Parameter(Mandatory = $true)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string[]] $FSLogixProfileRootPath, # FSLogix Folder Name Pattern. You can use %SID% or %username%. Default is: "%Username%_%SID%" [Parameter(Mandatory = $false)] [string] $FSLogixFolderPattern = "%Username%_%SID%", # FSLogix virtual disk default size in GB. [Parameter(Mandatory = $false)] [int] $FSLogixVHDSizeGB = 30, # FSLogix VHDX Name Pattern. You can use %SID% or %username%. Default is: "Profile_%Username%.VHDX" [Parameter(Mandatory = $false)] [ValidatePattern('\.VHDX{0,1}$')] # ErrorMessage = 'FSLogix VHD name must end with VHD or VHDX' [string] $FSLogixVHDXPattern = "Profile_%Username%.VHDX", # FSLogix command line tool path [Parameter(Mandatory = $false)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string] $FRXPath = 'C:\Program Files\FSLogix\Apps\frx.exe', # Log Folder Path [Parameter(Mandatory = $false)] [ValidateScript( { Test-Path -Path $_ -PathType Container })] [string] $LogFolderPath ) begin { } process { foreach ($user in $Username) { # Confirm username is correct and retrieve SID $sid = Get-CFXADUserSID -ErrorAction Stop #region: Calculate variables $fsLogixPathParams = @{ FSLogixProfileRootPath = $FSLogixProfileRootPath FSLogixFolderPattern = $FSLogixFolderPattern FSLogixVHDXPattern = $FSLogixVHDXPattern Username = $Username SID = $sid } $fslogixFilePath = Get-CFXFSLogixPath @fsLogixPathParams -ErrorAction Stop # Calculate name for FSLogix Folder and File # Check if FSLogix folder already exists, fail if so. # Calculate path for Citrix profile location #If profile not found, fail # Calculate path for Redirected folder profile location #If folder not found, fail # Calculate path for log file and confirm access. #endregion: Calculate variables # Create disk using FSLogix copy-profile # Copy redirected folders to disk using robocopy # Copy disk to profile location(s) #Log success or failure. } } } |