【发布时间】:2020-11-06 13:52:55
【问题描述】:
我正在尝试使用以下命令检查我的 Windows SMTP 服务器的 RelayForAuth 设置。 Powershell 似乎显示了正确的结果“False”,但是当通过命令提示符运行相同的命令时,它会产生错误:
Powershell 示例:
([ADSI]"IIS://localhost/smtpsvc/1".RelayForAuth -like "*0*")
输出:
False
命令提示符示例:
powershell -command "([ADSI]"IIS://localhost/smtpsvc/1".RelayForAuth -like "*0*")"
输出:
At line:1 char:8
+ ([ADSI]IIS://localhost/smtpsvc/1.RelayForAuth -like *0*)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'IIS://localhost/smtpsvc/1.RelayForAuth' in expression or
statement.
At line:1 char:8
+ ([ADSI]IIS://localhost/smtpsvc/1.RelayForAuth -like *0*)
+ ~
Missing closing ')' in expression.
At line:1 char:56
+ ([ADSI]IIS://localhost/smtpsvc/1.RelayForAuth -like *0*)
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
【问题讨论】:
-
现在将内部双引号更改为单引号。此外,您可以将工作行放在 powershell 脚本中并使用
powershell script.ps1运行它。
标签: windows powershell smtp command-prompt adsi