Suppose I have object $foo with many (500+) properties.
$foo.q1_sales = "1000"
$foo.q1_expense = "800"
$foo.q2_sales = "1325"
$foo.q2_expense = "1168"
$foo.q3_sales = "895"
$foo.q3_expense = "980"
$foo.q4_sales = "900"
$foo.q4_expense = "875"
...
I want to loop through all properties in $foo and get each value and process it in some way.
$quarters = @("1","2","3","4")
foreach($quarter in $quarters) {
if($foo.q$quarter_sales -gt $foo.q$quarter_expense) {
#process data
}
}
How do I accomplish this? Get-Variable? Get-Member? some combination? Some other way?
Changing the structure of $foo is not an option, unless we can do it programmatically. Sorry.