I'm trying to run an invoke-expression command within a foreach loop that uses a variable within a variable. Is this possible? Any pointers would be great.
Example
$CmdToRun = "Get-Process X -ComputerName $Server
$Servers = "1", "2", "3"
foreach ($Server in $Servers) {
Invoke-Expression $CmdToRun
}