Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter existence checking in functions treats $false value as no parameter #56

Open
TriggerAu opened this issue Oct 24, 2024 · 0 comments

Comments

@TriggerAu
Copy link
Contributor

TriggerAu commented Oct 24, 2024

In the situation where there is a boolean parameter and the parameter is part of one of the checks for value before use the logic in the functions treats a false as do not do the logic

I struck this when trying to use the New-OktaUser function and passing false to the activate function to prevent an email activation.

The example/scenario is

  1. Call the New-OktaUser -Body $body -Activate $false

  2. In the function this hits this line https://github.com/okta/okta-powershell-cli/blob/b01fd0a387e16d082ca833888fba9679a63527e9/src/Okta.PowerShell/Api/OktaUserApi.ps1#L626-628

  3. This logic reads the parameter and skips setting the value in the dictionary as $Activate is false

  4. The call to the API is made and the APIs value for this when not provided is True

  5. User is created and activated and messages get sent

From the code it looks like the logic is meant to be if this parameter was provided, ,but the logic is off

TriggerAu added a commit to TriggerAu/okta-powershell-cli that referenced this issue Dec 19, 2024
…ta#70)

Uses PSBoundParameter.ContainsKey rather than the if of the variable as
if the passed in value is 0 or $false the set is not done

same issue as okta#56, but in a different template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant