I have a XAML gui in my powershell script. I would like to know how I can use a string as a variable name ex. $grid.Name is WPFgrdCopy
This works:
$WPFgrdCopy.Background = "#FF212123"
This does not:
$grids = Get-Variable "wpfgrd*"
foreach($grid in $grids){
$grid.Background = "#FF212123"
}
It doesn't because $grid is an object of the variable, how can I set attributes of $grid.Name (WPFgrdCopy)
I have also tried Add-Member -InputObject $grid -NotePropertyMembers @{Background="#FF212123"} -Force