jantari / LSUClient

Orchestrate driver, BIOS/UEFI and firmware updates for Lenovo computers 👨‍💻
https://jantari.github.io/LSUClient-docs/
MIT License
208 stars 22 forks source link

Switch parameter ProxyUseDefaultCredentials - wrong syntax #70

Closed animentork closed 1 year ago

animentork commented 1 year ago

Version

1.5.1

Computer Model

all

Problem

Everywhere ProxyUseDefaultCredentials is used, you are really setting $ProxyUseDefaultCredentials to $true and then assign the value of $ProxyUseDefaultCredentials as a positional parameter to the first unused other parameter.

Example:

$webClient = New-WebClient -Proxy $Proxy -ProxyCredential $ProxyCredential -ProxyUseDefaultCredentials $ProxyUseDefaultCredentials

The value for the switch parameter should always be specified after the : separator:

$webClient = New-WebClient -Proxy $Proxy -ProxyCredential $ProxyCredential -ProxyUseDefaultCredentials:$ProxyUseDefaultCredentials

The value will otherwise be interpreted as a positional parameter, that means: as the first parameter not specified by name.

For example, if you forgot to use the -Proxy parameter when calling the function, $Proxy would instead be set to $false:

$webClient = New-WebClient -ProxyCredential $ProxyCredential -ProxyUseDefaultCredentials $false
--> $Proxy would be $false and $ProxyUseDefaultCredentials would be $true!

Additional context

No response

jantari commented 1 year ago

I'll be able to look into this next week

jantari commented 1 year ago

I tested this and you are absolutely right. I misremembered -Switch:$bool and -Switch $bool being equivalent, but now that you explain it ofc it doesn't make sense. It's also documented here.

Do you want to contribute fixes for this in a PR? Otherwise I'll do it myself - thank you either way!

jantari commented 1 year ago

Sorry for taking some time, but the fix for this is now released with LSUClient 1.5.2