A dumb module I created for some reason that adds an unless
function to PowerShell, which feels like a keyword in practice.
Logically similar to the if
keyword, but checks for a $false
result instead of $true
. Also supports chaining evaluations with else
-style clauses.
Currently you need to clone this repo and run Import-Module
against PSUnless.psm1
in order to import it.
Once imported, unless
is available for use from the current PowerShell session.
PSUnless
is intended to work with Windows PowerShell and PowerShell Core.
Basically, use unless
where you would use if
, but for negative conditions instead. For example:
$name = 'Mandark'
unless( $name -eq 'Susan' ) {
'My name is not Susan'
}
It also supports chaining else
-style clauses like else
, elseif
, and elseunless
. More information on the unless
function is located in docs/Function-Unless.md.
You can also view the same information in PowerShell with Get-Help unless
.
To build the docs you need to make sure to install the PlatyPS PowerShell module.
Edit the .md
files directly with a text editor, but make sure to follow the schema. The markdown has to be formatted in a particular way.
To generate the MAML files, run the following command from the repo root:
New-ExternalHelp -Path ./docs -OutputPath ./en-US -Force
This will generate en-US/PSUnless-help.xml. If the markdown in the source files violates the schema, New-ExternalHelp
will throw a related error.
Report any issues to the issue tracker.