1
我在构建ps1文件以通过appcmd创建所有IIS站点,虚拟目录和应用程序池的过程中。我已经使用appcmd list/xml从主机获取设置并将它们保存到配置文件中。我想获得PowerShell来执行APPCMD命令powershell使用/ IN <pathToFile执行appcmd
appcmd add apppool /IN < pathtoFile.xml
我的问题是PowerShell中的我无法使用比符号少:
PS C:\temp\deployments> .\createIISSetup.ps1
The '<' operator is reserved for future use.
At C:\temp\deployments\createIISSetup.ps1:36 char:28
+ .$appcmd add apppool /IN < <<<< $pathToAppPoolSettings;
+ CategoryInfo : ParserError: (<:OperatorToken) [], ParseException
+ FullyQualifiedErrorId : RedirectionNotSupported
如果我用管:
appcmd add apppool /IN | pathtoFile.xml
我得到:
PS C:\temp\deployments> .\createIISSetup.ps1
Expressions are only allowed as the first element of a pipeline.
At C:\temp\deployments\createIISSetup.ps1:36 char:51
+ .$appcmd add apppool /IN | $pathToAppPoolSettings <<<< ;
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline
欢迎来到StackOverflow。如果您提供答案,请解释您的代码正在做什么。 – sschale 2016-03-10 01:19:50