我正在构建一个ps1文件,以通过appcmd创建我的所有IIS站点、虚拟目录和应用程序池。我已经使用appcmd list /xml从主机获取设置,并将它们保存到配置文件中。我试图让powershell执行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发布于 2012-03-20 20:59:43
一个同事给了我这个问题的答案。把它倒过来就行了:
type $pathToapppoolSettings | .$appcmd add apppool/IN; 这很好用。
发布于 2016-03-10 09:09:23
Get-Content appppols.xml | .\appcmd.exe add apppool /inhttps://stackoverflow.com/questions/9786864
复制相似问题