An if statement can include an assignment step as follows:
if ($i = 1) { Write-Host "Implicit true. The variable i is $i" }
This is most commonly used when testing for the existence of a value in a variable, for example:
if ($interface = Get-NetAdapter | Where-Object Status -eq 'Up') { Write-Host "$($interface.Name) is up"
}
In the previous example, the statement to the right of the assignment operator (=) is executed, assigned to the variable $interface, then the value in the variable is treated as an implicit Boolean.