Variables Powershell if语句未执行

Variables Powershell if语句未执行,variables,powershell,if-statement,conditional-statements,Variables,Powershell,If Statement,Conditional Statements,我有下面的代码片段a powershell脚本和嵌套的if语句没有执行。你能告诉我为什么吗?我最近又回到了编程游戏中,所以它可能很简单 $false. $IgnoreThisLine = $false $tmpString = "(DATUM CTR OF BLADE)" $EndOfDescription = $null $cncPrograms ="(165756 SIDE 1)" if ($IgnoreThisLine = $false ) { If ($tmpString

我有下面的代码片段a powershell脚本和嵌套的if语句没有执行。你能告诉我为什么吗?我最近又回到了编程游戏中,所以它可能很简单

$false. 
$IgnoreThisLine = $false
$tmpString = "(DATUM CTR OF BLADE)"
$EndOfDescription = $null 
$cncPrograms ="(165756 SIDE 1)"

if ($IgnoreThisLine = $false ) {
    If ($tmpString -match '\(') {
        $EndOfDescription =  $false
        $cncPrograms = $tmpString 
        }
    else {
    $EndOfDescription = $true               
    }
}

“-eq”not“=”来测试与PowerShell的相等性。

+1-OP应该知道他的
IF
块实际上只是将
$ignorethisline
变量重新分配到
$false
,然后根据该分配是否成功执行布尔值,您甚至不需要这样做。如果(-not$IgnorethisLine)等于false,则与测试相同。如果您想测试某个值是否为真:If($IgnoreThisLine){“I am true”}else{“I am false”}
if ($IgnoreThisLine -eq $false)