rmbolger / Posh-IBWAPI

PowerShell module for interacting with the Infoblox WAPI (REST API).
MIT License
54 stars 8 forks source link

Cannot bind argument to parameter 'Value' because it is an empty string #47

Closed bjtukker closed 4 years ago

bjtukker commented 4 years ago

Hi,

We're using the InfoBlox appliance for quite some time now, and last week updated from Posh-IBWAPI version 1.6.something to the latest, 3.1.0. We have a nightly pipeline to create a test configuration and that was working fine, until today. We now receive errors on running the pipeline:

2020-03-10T15:13:41.6380548Z ##[debug]Caught exception from task script. 2020-03-10T15:13:41.6420437Z ##[debug]Error record: 2020-03-10T15:13:41.6908695Z ##[debug]Set-IBConfig : Cannot bind argument to parameter 'Value' because it is an empty string. 2020-03-10T15:13:41.6922893Z ##[debug]At C:\agent1_work\r18\a\DNS Team Zones\scripts\New-DevOpsTeamDnsSubZones.ps1:169 char:1 2020-03-10T15:13:41.6934117Z ##[debug]+ Set-IBConfig -WAPIHost $infobloxHost -WAPIVersion 'latest' -Credentia ... 2020-03-10T15:13:41.6945704Z ##[debug]+ ~~~~~~~~~~~~~~~~~ 2020-03-10T15:13:41.6957037Z ##[debug] + CategoryInfo : InvalidData: (:) [Set-IBConfig], ParameterBindingValidationException 2020-03-10T15:13:41.6968852Z ##[debug] + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Set-IBConfig 2020-03-10T15:13:41.6983993Z ##[debug] 2020-03-10T15:13:41.7003689Z ##[debug]Script stack trace: 2020-03-10T15:13:41.7036789Z ##[debug]at , C:\windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules\Posh-IBWAPI\3.1.0\Public\Set-IBConfig.ps1: line 5 2020-03-10T15:13:41.7050122Z ##[debug]at Set-IBConfig, C:\windows\ServiceProfiles\NetworkService\Documents\WindowsPowerShell\Modules\Posh-IBWAPI\3.1.0\Public\Set-IBConfig.ps1: line 35 2020-03-10T15:13:41.7063488Z ##[debug]at , C:\agent1_work\r18\a\DNS Team Zones\scripts\New-DevOpsTeamDnsSubZones.ps1: line 169 2020-03-10T15:13:41.7078392Z ##[debug]at , C:\agent1_work\r18\a\DNS Team Zones\scripts\Create-SubZonesFromConfig.ps1: line 99 2020-03-10T15:13:41.7090548Z ##[debug]at , : line 1 2020-03-10T15:13:41.7103402Z ##[debug]at , C:\agent1_work_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\3.153.3\AzurePowerShell.ps1: line 145 2020-03-10T15:13:41.7115263Z ##[debug]at , C:\agent1_work_tasks\AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62\3.153.3\AzurePowerShell.ps1: line 141 2020-03-10T15:13:41.7126617Z ##[debug]at , : line 1 2020-03-10T15:13:41.7138836Z ##[debug]at , : line 22 2020-03-10T15:13:41.7150184Z ##[debug]at , : line 18 2020-03-10T15:13:41.7162047Z ##[debug]at , : line 1 2020-03-10T15:13:41.7180980Z ##[debug]Exception: 2020-03-10T15:13:41.7230463Z ##[debug]System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Value' because it is an empty string. 2020-03-10T15:13:41.7241876Z ##[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) 2020-03-10T15:13:41.7253898Z ##[debug] at System.Management.Automation.Interpreter.ActionCallInstruction2.Run(InterpretedFrame frame) 2020-03-10T15:13:41.7267265Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2020-03-10T15:13:41.7280053Z ##[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2020-03-10T15:13:41.7292983Z ##[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame) 2020-03-10T15:13:41.7306268Z ##[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0) 2020-03-10T15:13:41.7318104Z ##[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action1 clause, Object dollarUnderbar, Object inputToProcess) 2020-03-10T15:13:41.7330148Z ##[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing() 2020-03-10T15:13:41.7341929Z ##[debug] at System.Management.Automation.CommandProcessorBase.Complete() 2020-03-10T15:13:41.7563003Z ##[error]Cannot bind argument to parameter 'Value' because it is an empty string.

At this point the following is being called: Set-IBConfig -WAPIHost {our.ip.address} -WAPIVersion 'latest' -Credential System.Management.Automation.PSCredential -SkipCertificateCheck

Any ideas what's causing this?

rmbolger commented 4 years ago

The config related functions in 2.0 were changed to have a -ProfileName parameter and old 1.x configs were automatically migrated to the new format by using what was previously set for WAPIHost as the profile name.

Using Set-IBConfig without a profile name should still work. It would effectively just change the associated settings for the current profile. But it looks like there's a bug that causes the parameter binding error you're getting if no current profile is set.

For the time being, you can workaround the bug by adding a -ProfileName {our.ip.address} to your Set-IBConfig command.

I'll see what I can do about fixing the bug, but it might just be a better error message because it still won't know what to do with the config settings when there's no current profile selected.

rmbolger commented 4 years ago

The bug is now fixed in 3.1.1, but all it really does is handle the error with a more appropriate error message so you know what's wrong. In your case, you'll likely still need to modify your script to add the -ProfileName parameter to your Set-IBConfig call.

bjtukker commented 4 years ago

Thanks for the quick fix! It's working with the added parameter. I couldn't figure out why or where it was failing, because we used the Set-IBConfig for quite some time without the profilename parameter.