Summary: I've noticed a strange behaviour (in WFA 4.0 and 4.1) when writing a Perl commandlet. Although I define the parameters correctly (I think), they are not passed to the perl code properly unless I actually craft a Powershell param() equivalent and use that to discover the parameters.
Take this simple example:
use strict;
use warnings;
use Getopt::Long;
use WFAUtil;
use Data::Dumper;
my $wfa_util = WFAUtil->new();
my $success = 'true';
GetOptions(
"success:s" => \$success
) or die 'Illegal command parameters\n';
$wfa_util->sendLog('INFO', 'Success: ' . $success);
I define a parameter "success" as a boolean on the "Parameters Definition" tab and the "Parameters Mapping" tab is populated automatically. Now when I run this commandlet, I always get "Success: true" despite what value I select on the test. Diving into the perl specifics, it looks like the parameter is passed only after a '--' argument which causes GetOptions to ignore the parameter.
The only way to get aroud this seems to be to define a minimal PowerShell script which can be used to discover the same parameter (i.e. the config tabs look exactly the same as before after the discovery):
param (
[parameter (Mandatory=$False, HelpMessage="None")]
[boolean]$success
)
And then suddenly the Perl code works as expected.
Now, maybe I missed something obvious and this is not a bug which is why I post it here before opening up a ticket with support. Any ideas anyone?