Hi @SakeriyeMohamud-4520,
by default all Powershell parameters are optional, meaning that you don't have to provide a value by default. So, designing your param section like this, should accomplish the goal:
From the same article, I've posted previously:
By default, PowerShell parameters are optional. When a user does not submit arguments to a parameter, PowerShell uses its default value. If no default value exists, the parameter value is $null.
The easiest way is to check each parameter for $null, then follow whatever logic you have from there. This will result in something like this:
param(
[string]$CallNodeSKU,
)
if($CallNodeSKU -neq $null)
{
#Do stuff here
}
or you can use this one:
$PSBoundParameters
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.2#psboundparameters
Contains a dictionary of the parameters that are passed to a script or function and their current values. This variable has a value only in a scope where parameters are declared, such as a script or function. You can use it to display or change the current values of parameters or to pass parameter values to another script or function.
and do it like this:
param(
[string]$CallNodeSKU,
)
if($PSBoundParameters.ContainsKey("CallNodeSKU"))
{
#Value has been provided for the param CallNodeSKU
#Do stuff here
}
Hope this helps you out.
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Stoyan Chalakov