I’d like to create an action parameter whereby the console operator can define the external IP address of a machine. Rather than it being a free-form text entry field, I’d like for the text entry to be restricted to the IP address format, e.g.:
I don’t think that’s supported. I think you will have to accept whatever the user types in, then in your actionscript validate their entry using a regular expression that only matches IPv4 addresses. Then you can use something like the “continue if” statement to bail out early if needed.
My bad, I didn’t actually read that document that you helpfully provided… I thought you were asking about the “action parameter query” command in actionscript.
But if you look on page 13 of that document, they do provide a way to create a custom validation function as shown in the “validatePort” example. So you could create a similar function that validated against a IPv4 regular expression, before you got into the action.
Thanks Sean. I has seen the validation and presume I could validate to make sure a number is between say 0 and 255, but I’m still not sure how to concatenate the four octets with a period… maybe I would just have to request them as four separate values with validation? E.g:
validateIP : function (validationObj ) {
var currentValue = validationObj["currentValue"];
if ( currentValue < 0 || currentValue > 255 ) {
return "IP octet specified [“+currentValue+”] is outside of valid range of 0-255";
}
}
<Value><![CDATA[{
"1IP": {
"Name": "firstIP",
"Title": "First Octet:",
"Description": "Enter the first octet",
"UIType": "Textbox",
"CustomValidator" : "validateIP"
},
"2IP": {
"Name": "secondIP",
"Title": "Second Octet:",
"Description": "Enter the second octet",
"UIType": "Textbox",
"CustomValidator" : "validateIP"
}
"3IP": {
"Name": "thirdIP",
"Title": "Third Octet:",
"Description": "Enter the third octet",
"UIType": "Textbox",
"CustomValidator" : "validateIP"
}
"4IP": {
"Name": "fourthIP",
"Title": "Fourth Octet:",
"Description": "Enter the fourth octet",
"UIType": "Textbox",
"CustomValidator" : "validateIP"
}
}]]></Value>
Just not sure if a) the above is correct, and b) if so, where to go from there!
OK, so working through the how-to document, it’s not laid out in a very clear manner where exactly all of these individual parts tie together, but I did eventually successfully create and import the default parameterized fixlet from the following sections:
BES File Template
Bootstrap Section
Parameter Metadata Tag (Parameter)
Action Section
After importing, I made some fixlet description changes, exported again and modified the fields (for the last two sections) to my requirements for: Parameter Metadata Tag, Parameter Validator Tags, and the ActionScript (to write the inputted External IP Address to a registry key) as such:
(Note: the below code directly follows the “SANSID” entry if you are using the default template…)
<MIMEField>
<Name>ParameterMetadataTag</Name>
<Value><![CDATA[{
"IP_Address": {
"Name": "IPAddress",
"Title": "External IP Address:",
"Description": "Enter the External IP address",
"UIType": "Textbox",
"CustomValidator" : "validateIP"
}
}]]></Value>
</MIMEField>
<MIMEField>
<Name>ParameterValidatorTag</Name>
<Value><![CDATA[{
validateIP:function(validationObj) {
var currentValue=validationObj["currentValue"];
if ( !currentValue.match(/^([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3}).([0-9]{1,3})$/))
return "The IP specified is invalid";
}
}]]></Value>
</MIMEField>
<MIMEField>
<Name>x-fixlet-modification-time</Name>
<Value>Tue, 19 Apr 2016 15:41:43 +0000</Value>
</MIMEField>
<Domain>BESC</Domain>
<DefaultAction ID="Action1">
<Description>
<PreLink>Click </PreLink>
<Link>here</Link>
<PostLink> to deploy this action.</PostLink>
</Description>
<ActionScript MIMEType="application/x-Fixlet-Windows-Shell">//
if {x64 of operating system}
regset64 "[HKLM\Software\MyCompany\BigFix]" "External IP"="{parameter "IP_Address" of action}"
else
regset "[HKLM\Software\MyCompany\BigFix]" "External IP"="{parameter "IP_Address" of action}"
endif
</ActionScript>
</DefaultAction>
</Fixlet>
I now have a lovely fixlet that requests user input in the IP address format, and kicks if anything other than integers 0-9 are used. It’s not sophisticated enough to lock down entry to only numbers <255, so that’ll be the next step.