1

The values of the variables are: a = 3, b = 6, and c = 2 d=6 The result should be the name of the variable that contains the maximum value— the text b&d i.e the result of maximum value.

0

1 Answer 1

1
$a = 3
$b = 6
$c = 2
$d = 6

$Variables = Get-Variable -name a,b,c,d
$Variables | Where { $_.Value -eq ($Variables | Measure-Object Value -Maximum).Maximum } | Select Name

Use Measure-Object to get the largest (maximum) value from the set of variables, then use Where-Object to filter the collection of variables to those with that maximum value and return their names via Select-Object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.