Working on passing data from an external application calling a Powershell script. It would be called something like this:
& powershell.exe -File C:\Users\rasim\Desktop\temp.ps1 -Param $[RemoteApplicationVar]
Powershell does not want to let me pass a nullable string, which I might add is rather frustrating. Look at the following example:
function Test-It {
param (
[Parameter(Mandatory=$true)]
[AllowNull()]
[AllowEmptyString()]
[string]$MyParam
)
$MyParam
}
Test-It -MyParam
Emulating that the variable would contain nothing and making in not mandatory, allow null and allow empty string it still errors with:
C:\Users\rasim\Desktop\temp.ps1 : Missing an argument for parameter 'Param'. Specify a parameter of type 'System.Object' and try again.
+ CategoryInfo : InvalidArgument: (:) [temp.ps1], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument,temp.ps1
Has anyone dealt with this. I’m open to suggestions like passing the variables as a big string (e.g Param1,Param3) and then dealing with it but was trying to actually map to named params vs passing something like a CSV row to the script. Any thoughts?