Bug in parameter validation in FSLogix.ps1
- Dominant language
- PowerShell
- Stars
- 524
- Forks
- 610
- PR merge metrics
- No merged PRs in 30d
Description
hello team, there is a bug in the validation [here](https://github.com/Azure/RDS-Templates/blob/master/CustomImageTemplateScripts/CustomImageTemplateScripts_2023-05-16/FSLogix.ps1#L100)
This script isn't validating empty string correctly using $PSBoundParameters.ContainsKey('ProfilePath'). Azure Portal is sending an empty string but this is **always** returning true.
Azure Virtual Desktop Image Builder is adding **CCDLocations** to VM registry as "**type=smb,connectionString=**" because $ProfilePath is empty.
Azure Portal says it is optional to send "Profile path", and when doing so, the script won't correctly validate empty or null string.

Same test.ps1:
```
Param (
[Parameter(Mandatory=$false)]
[string]$ProfilePath
)
$PSBoundParameters.ContainsKey('ProfilePath') #<-- will return true with empty string
```
PS C:\> .\test.ps1 -ProfilePath ""
True
PS C:\>
This is what gets added to HKLM\Software\FSLogix\Profiles

Please make sure $ProfilePath validated for not being null or empty, otherwise, when logging on to the VM using FSLogix, it will throw error below:
[16:42:21.826][tid:00000ba4.00001350][ERROR:00000021] LoadProfile failed. Version: 2.9.8171.14983 User: . SID: . SessionId: 6. FrxStatus: 33 (The process cannot access the file because another process has locked a portion of the file.)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at CustomImageTemplateScripts/CustomImageTemplateScripts_2023-05-16/FSLogix.ps1 around line 100 and compare its ProfilePath validation with the provided test.ps1 behavior. Verify the script when ProfilePath is empty or null, and confirm that it no longer adds an empty CCDLocations value to the VM registry; reproduce the scenario through the script's existing validation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100