Optional parameters are $null rather than ""

I’m using the “SQL - Drop Database Using SMO” community step in my project. It has 2 optional parameters ($SqlUsername and $SqlPassword) which I am not using but the script is failing as it is trying to use them.

The script has the clause if ($SqlUsername -eq "" -and $SqlPassword -eq "") but the parameter being passed is $null.

To confirm this I created a sample script step of:

Write-Host "Optional is:$optional"
if ($optional -eq ""){
    Write-Host 'optional is empty'
if ($optional -eq $null){
    Write-Host 'optional is null'

The output in the logs is ‘optional is null’.

I recently updated my Octopus Server from 3.10.0 to 3.11.16 but can’t see anything in the change logs that would relate to this. I’m presuming that the optional value was "" at some point as it is in the community step, has this changed to $null? If this is expected I’m happy to change the community steps and submit a PR.

Hi Donald,

Thanks for getting in touch! I’m not aware of any changes but I suppose it would be a good idea to check if the parameter is $null or empty. In this way the code can be made much more reliable.

It would be amazing if you could submit a PR with this change.