I have four variables, and I need to check if they are equal or greater than 512. If a variable's value is less than 512, then that variable should be assigned the value of 512.
$a = 512
$b = 256
$c = 512
$d = 1024
if(!($a, $b, $c,$d | Where {$_ -ge 512})) {
#do some stuff
}
else {
#here I need to write code like it should make variable ($b) equal to 512.
}
These variables are not predefined in my code. It will be given by someone who runs the pipeline. So my code should be like: set the variable's value to 512, which are less than 512.
If you know the variable names, you can use the Get-Variable
function
Get-Variable -Name ('a','b','c','d') | % {if ($_.Value -lt 512) {$_.Value = 512}}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments