Skip to content

Instantly share code, notes, and snippets.

@xinmyname
Created August 8, 2022 17:14
Show Gist options
  • Save xinmyname/99d699225f4fcd416821ebfce5f71633 to your computer and use it in GitHub Desktop.
Save xinmyname/99d699225f4fcd416821ebfce5f71633 to your computer and use it in GitHub Desktop.
Coalesce PowerShell arguments
function Coalesce-Args {
$result = $null
foreach($arg in $args) {
if ($arg -is [ScriptBlock]) {
$result = & $arg
} else {
$result = $arg
}
if ($result) { break }
}
$result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment