internal/functions/Get-CFXLogixPath.ps1
function Get-CFXFSLogixPath { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string[]] $FSLogixProfileRootPath, # FSLogix Folder Name Pattern [Parameter(Mandatory = $false)] [string] $FSLogixFolderPattern, # FSLogix VHDX Name Pattern [Parameter(Mandatory = $false)] [string] $FSLogixVHDXPattern, # Username used for logon (SAMAccountName) [Parameter(Mandatory = $true)] [string] $Username, # Active Directory SID of the user [Parameter(Mandatory = $true)] [string] $SID ) begin { # Calculate Profile Folder name $profileFolderName = $FSLogixFolderPattern -replace "%SID%",$SID -replace "%username%",$Username if($profileFolderName -like "*%*") {throw "Could replace all maps in ($FSLogixFolderPattern). Please only use %SID% or %Username%."} # Calculate profile virtual disk name $profileFolderName = $FSLogixVHDXPattern -replace "%SID%",$SID -replace "%username%",$Username if($profileVHDXName -like "*%*") {throw "Could replace all maps in ($FSLogixFolderPattern). Please only use %SID% or %Username%."} } process{ foreach ($provider in $FSLogixProfileRootPath){ $path = Join-Path $provider $profileFolderName $profileVHDXName Write-PSFMessage -Level Verbose -Message "Caluclated path for $username on $provider as: $path" } } end{ } } |