I have the following code which works:
foreach ($db in $svr.Databases |
where-object {
$_.name -eq "testDB"
-or $_.name -eq "master"
-or $_.name -eq "model"
-or $_.name -eq "msdb" } )
{
write-output $db.name
}
Is a cleaner way to do this?
Something like:
foreach ($db in $svr.Databases |
where-object {$_.name -in "testDB, master, model, msdb" } )
{
write-output $db.name
}
-in
operator in powershell – Karrikarrie