Reputation: 105
So here's a kind of a silly problem. Can someone explain how this makes sense? I don't really know what else to ask. Why would the if statement change the value of the variable in it?
PS C:\Users\HD2> $format = 6
PS C:\Users\HD2> $format
6
PS C:\Users\HD2> if($format = 1){write-host "woo"}
woo
PS C:\Users\HD2> $format
1
Upvotes: 2
Views: 293
Reputation: 2214
In powershell, the =
operator is used to assign values to a variable. To do comparison, use the -eq
operator.
Upvotes: 5