I am writing cmdlets in C# and I have nullable ints (int?) which I took care of with [System.Nullable[System.Int32]] in my powershell script.
Now, however, I have some parameters that are not required that are strings and I need them to pass null if they are not supplied when calling the script and not an empty string. Is there something similar to [System.Nullable[System.Int32]] I can use?
(C#)
[Cmdlet("Update","Name")]
public class UpdateName : Cmdlet
{
public UpdateName()
{
}
[Parameter(HelpMessage = "The Name")]
public string Name { get; set; }
[Parameter(HelpMessage = "The Number")]
public int? Number { get; set; }
proctected override void ProcessRecord()
{
// do stuff here
}
}
(Powershell)
[CmdletBinding()]
param
( [string]$Name,
[System.Nullable[System.Int32]]$Number
)
Update-Name -Name $Name -Number $Number
And then I am calling my script testscript.ps1 and running it with no parameters passed from my powershell prompt.