AaronJAnderson
AaronJAnderson

Reputation: 1724

powershell "if" needs to set two variables on match

I need to set two variables in a script...

The first is obviously $vmcluster - What's the proper syntax to set another variable if my "if" matches?

if ($vmname -like "LouPr*") {$vmcluster = "Production"}

Upvotes: 1

Views: 2057

Answers (1)

Frode F.
Frode F.

Reputation: 54881

It's a script-block.... just use another line, or seperate with ; .

if ($vmname -like "LouPr*") { 
    $vmcluster = "Production"
    $secondvar = "secondvalue"
    }

or

if ($vmname -like "LouPr*") { $vmcluster = "Production"; $secondvar = "secondvalue" }

Upvotes: 5

Related Questions