baramundisoftware / PS-bConnect

Powershell module for baramundi Connect (bConnect), the REST-API of the baramundi Management Suite
https://www.baramundi.com/en/management-suite/interfaces/
MIT License
26 stars 14 forks source link

Get-bConnectVariableDefinition with Category parameter does not work #68

Closed uka-support closed 2 years ago

uka-support commented 2 years ago

Prior to placing the issue, please check following: (fill out each checkbox with an X once done)

Describe the bug When calling Get-bConnectVariableDefinition -Scope Device -Category "somecategory", the request fails.

To Reproduce Steps to reproduce the behavior:

  1. Initialize bConnect module
  2. Run Command 'Get-bConnectVariableDefinition -Scope Device -Category "somecategory"'
  3. Exception thrown:
    Invoke-bConnectGet : Invalid request. Unexpected parameters: Category=somecategory
    In C:\Program Files\WindowsPowerShell\Modules\bConnect\21.1.0.0\Public\Get-bConnectVariableDefinition.ps1:52 Zeichen:16
    + ...      return Invoke-bConnectGet -Controller "VariableDefinitions" -Ver ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-bConnectGet

Expected behavior Request should work :-)

System information Question Answer
My operating system Windows Server 2016
Powershell Version 5.1.14393.5066
baramundi Server Version 2021R2
PS-bConnect Version 21.1.0.0

Additional context Discussion in forum

I'm not sure what's going on here.

My conclusion: something obscure within the bConnect module? Or yet another Powershell strange behaviour?

T0biii commented 2 years ago

now if i only call Get-bConnectVariableDefinition -id $id i get this: image ![string]::IsNullOrEmpty didn't help me

uka-support commented 2 years ago

Ah, I see. If I use -Scope that is ignored anyway because I pass "Device"! And category and name may only be used when scope is used too.

Well, the "Device" get's assigned integer value 0 in that enum, so there's no easy way to check whether the parameter has been passed to the function or not.

Maybe make the comparison explicit: if ($Scope -ne $null)?

$Scope = [bConnectVariableScope]::Device
if ($Scope) { echo "yo" }
if ($Scope -ne $null) { echo "yo" }

Other solution: assign explicit numbers to the bConnectVariableScope, starting with 1, not 0.