Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,47 @@
|
|||
function When-Condition
|
||||
{
|
||||
[CmdletBinding()]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true, Position=0)]
|
||||
[bool]
|
||||
$Test1,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=1)]
|
||||
[bool]
|
||||
$Test2,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=2)]
|
||||
[scriptblock]
|
||||
$Both,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=3)]
|
||||
[scriptblock]
|
||||
$First,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=4)]
|
||||
[scriptblock]
|
||||
$Second,
|
||||
|
||||
[Parameter(Mandatory=$true, Position=5)]
|
||||
[scriptblock]
|
||||
$Neither
|
||||
)
|
||||
|
||||
if ($Test1 -and $Test2)
|
||||
{
|
||||
return (&$Both)
|
||||
}
|
||||
elseif ($Test1 -and -not $Test2)
|
||||
{
|
||||
return (&$First)
|
||||
}
|
||||
elseif (-not $Test1 -and $Test2)
|
||||
{
|
||||
return (&$Second)
|
||||
}
|
||||
else
|
||||
{
|
||||
return (&$Neither)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
When-Condition -Test1 (Test-Path .\temp.txt) -Test2 (Test-Path .\tmp.txt) `
|
||||
-Both { "both true"
|
||||
} -First { "first true"
|
||||
} -Second { "second true"
|
||||
} -Neither { "neither true"
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Set-Alias -Name if2 -Value When-Condition
|
||||
|
||||
if2 $true $false {
|
||||
"both true"
|
||||
} { "first true"
|
||||
} { "second true"
|
||||
} { "neither true"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue