这个powershell脚本有什么问题?

时间:2017-01-04 22:35:46

标签: powershell

如此努力,我无法弄清楚它有什么问题。它可能会变得微不足道,令人尴尬,我放弃了

Param(
[string]$i = "",
 [int]$start,
 [int]$end,
 [int]$width,
 [int]$height,
 [string]$o = ""
)

if ($i.Length == 0 or $o.Length == 0 or ($width == 0 and $height == 0)) 
{
    Write-Host "input, output, either of width of height are required"
    Exit
}
$sum = $start + $end
if ( not ($sum==0) and ($sum == $start or $sum == $end))
{
    Write-Host "When either of the start or end is supplied, the other has to be supplied too"
    Exit
}

 $widthString = $width.ToString()
 $heightString = $width.ToString()

if (($width -ge 0) and $height==0) 
{
}

Error shown on the ISE

1 个答案:

答案 0 :(得分:5)

您已将此标记为PowerShell,因此我认为这是您尝试撰写的语言?

您的令牌在PowerShell中无效,可以找到一个比较好的逻辑运算符列表here

简而言之,==应为-eqand应为-andor应为-or,依此类推。< / p>