Incorrect handling of genericfields when using new-passwordstatepassword
On line 169 there is the following code
$GenericFields = Get-Variable GenericField* | Where-Object { $_.Value -ne [NullString] -and $null -ne $_.Value }
This returns all GenericFields, even if they are $null
In order to make this work it should be adjusted to this
$GenericFields = Get-Variable GenericField* | Where-Object { -not [string]::IsNullOrEmpty($_.Value) }
Apparently there is also a bug with the passwordstate-api when you pass "" in an encrypted field, that it encrypts an empty value, witch results in an error when trying to disable the encryption, we've already passed this through to clickstudios
@rousseauxy I may be interpreting what you are saying wrong but it seems to work as intended for me and doesn't return the null generic fields?
$genericfield1 = 1
$genericfield2 = $null
Get-Variable GenericField* | Where-Object { $_.Value -ne [NullString] -and $null -ne $_.Value }
This gives the following output
Name Value
---- -----
genericfield1 1
Where the null valued genericfields are excluded. To be clear your method works as well but there isn't anything wrong with the current method as far as i can tell?
@dnewsholme with the issue we were facing we did some debugging (in visual code, powershell 5.1) and the value returned was
Name Value
genericfield1 1
genericfield2 ''
$_.Value -ne [NullString] didn't do anything So all the genericfields were passing empty strings to the api
With your code above i can't simulate the issue, but i can do some testing tomorrow at work
Closing as no update on this. Don't think this is an issue.