microsoft / diskspd

DISKSPD is a storage load generator / performance test tool from the Windows/Windows Server and Cloud Server Infrastructure Engineering teams
MIT License
1.16k stars 215 forks source link

New-Fleet ConnectPass parameter special characters handling #185

Closed rosenbom closed 5 months ago

rosenbom commented 2 years ago

The issue: if ConnectPass contains "," or some other special characters, run.ps1 inside VM will fail, because "connectpass" parameter is passed as is (no quotes).

VMFleet line 2331 replaces parameters in the VM script: (Get-Command Set-FleetLauncherScript).ScriptBlock |% { $_ -replace 'CONNECTUSER',$using:connectuser -replace 'CONNECTPASS',$using:connectpass } > z:\users\administrator\launch.ps1

The fix is easy, just single quotes to $using:connectpass. Unfortunately, github editor doesn't allow to put escape char - it assumes it's a code block, so I'm replacing it with "&esc"

Repro: non-working: $p = "A1B2C3,D4E5F6!" $string = New-Object psobject $c = "&esc$string | Add-Member -MemberType NoteProperty -Name pass -Value CONNPWD" $c2 = $c -replace 'CONNPWD',$p Invoke-Expression $c2 $string.pass working: $p = "A1B2&esc"C3,D4E5F6!" $string = New-Object psobject $c = "&esc$string | Add-Member -MemberType NoteProperty -Name pass -Value CONNPWD" $c2 = $c -replace 'CONNPWD',"&esc'$p&esc'" Invoke-Expression $c2 $string.pass

Yes, still some special chars needs additional handling, but at least it's better than nothing.

Thanks, Dmitry.

dl2n commented 5 months ago

This should be fixed in the newest version.