PowerShell, call script with parameter without a value, like a script with options

Set the type of your parameter to [switch], e.g.

param (
    [switch]$lastmonth
);

EDIT:
Note that the variable will be a boolean. You can test it like:

if ($lastMonth) {
    Write-Host "lastMonth is set."
}
else {
    Write-Host "lastMonth is not set."
}

(thanks Chris)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)