Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Test-Ternary {
- param(
- [parameter(Mandatory,ValueFromPipeline)]
- $Condition,
- [parameter(Mandatory,Position=1)]
- $IsTrue,
- [parameter(Mandatory,Position=2)]
- $IsFalse
- )
- $test = $Condition
- if($Condition -is [scriptblock]){
- $test = &$Condition
- }
- if($test){
- if($IsTrue -is [scriptblock]){
- &$IsTrue
- } else {
- $IsTrue
- }
- } else {
- if($IsFalse -is [scriptblock]){
- &$IsFalse
- } else {
- $IsFalse
- }
- }
- }
- #Get-Process -Name notepad -ErrorAction SilentlyContinue | ?? "Notepad started" "Notepad not started"
- Set-Alias ?? Test-Ternary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement