Created
September 17, 2024 13:29
-
-
Save Calvindd2f/316762ebaed93309fa9ee9ca13f703c5 to your computer and use it in GitHub Desktop.
Invoke-Coalesce function and Invoke-IfTrue function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Invoke-Coalesce ($value, $default) | |
| { | |
| # Use IsNullOrEmpty instead of -not | |
| if ([String]::IsNullOrEmpty($value)) { $value = $default } | |
| return $value | |
| } | |
| function Invoke-IfTrue ($expression, $valueIfTrue, $valueIfFalse) | |
| { | |
| if ($expression) { return $valueIfTrue } | |
| else { return $valueIfFalse } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment