我收到错误:
You must provide a value expression on the right-hand side of the '-and' operator.
At C:\shippinginterface\test.ps1:28 char:39
+ if (($TicketNumber.length -gt 0) -and <<<< IsNumeric($TicketNumber) -and IsNotVoid($DateOut))
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpectedValueExpression
运行此测试脚本时。
function IsNumeric($value) {
return ($($value.Trim()) -match "^[-]?[0-9.]+$")
}
function IsNotVoid($value) {
$VoidPattern = [regex]"(?i)void"
return !$VoidPattern.Match($value).Success
}
############################
# START TEST
############################
$TicketNumber = "12345"
$DateOut = "3/14/2013"
## Verify there is a numeric ticket number, and row is not void for any reason
if (($TicketNumber.length -gt 0) -and IsNumeric($TicketNumber) -and IsNotVoid($DateOut))
{
write-host $intRow " " $TicketNumber
}
为什么它不喜欢我的使用-and
?如果我删除 string.length 的第一个评估,则该语句按预期工作。