rancher/wins

Wins Installer Script needs to test for registry key first.

Closed this issue · 0 comments

If registry key doesn't exist the following error occurs.

>>         $PROXY_ENV_INFO = Get-ChildItem env: | Where-Object { $_.Name -Match "^(NO|HTTP|HTTPS)_PROXY" } | ForEach-Object { "$($_.Name)=$($_.Value)" }
>>         if ($PROXY_ENV_INFO) {
>>             $newEnv += $PROXY_ENV_INFO
>>             Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\$serviceName -Name Environment -PropertyType MultiString -Value $newEnv
>>         }
Set-ItemProperty : A parameter cannot be found that matches parameter name 'PropertyType'.
At line:5 char:100
+ ... trolSet\Services\$serviceName -Name Environment -PropertyType MultiSt ...
+                                                     ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-ItemProperty], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand

Before calling Set-ItemProperty we need to test that it exists first and if it doesn't call New-ItemProperty, if it does, call Set-ItemProperty