Hello
Is ist possible to put IF statements in a variable? I have six different rules and I don't want to have six times the hole code in there. So I would like to have on code sniplet and just replace the Rule as variable. For example:
$SaraRule1 = ($VmDs.Name.Substring(3,1) -eq "p") -and ($VmDs.Name.split("_")[$VmDs.Name.split("_").count -1] -eq "zrh")
Foreach ($Vm in $VmList) {
$VmDs = $Vm | Get-Datastore
If ($SaraRule1) {
Write-Host "VM $Vm liegt auf Datastore $VmDs und kommt in DRS Group INT-VM-ZRH"
$NewVmList += ,$Vm.Name
}
}
This example is always "false" as output and is not working. I don't know if its possible?
Thx,
Chris