【发布时间】:2019-04-15 21:58:59
【问题描述】:
我想在 Powershell 中使用 appcmd 和 Invoke-Command 来添加虚拟目录。
我使用的参考来自: 1)appcmd to create virtual directory 2)Powershell Invoke-Command
这里是sn-p的代码:
$appCmdCommand2 = [string]::Format(
{"appcmd.exe set config -section:system.applicationHost/sites /+"[name='Default Web Site'].[path='/'].[path='/MyWebsite/dev',physicalPath='{0}']" /commit:apphost"},$folderName)
Invoke-Command -ComputerName ComputerAA -ScriptBlock {$appCmdCommand2}
当我运行上面的代码时,我不断收到错误消息:
Unexpected token 'name='Default Web Site'].[path='/'].[path='/MyWebsite/dev'' in expression or statement.
我是 Powershell 新手,我一直在到处寻找如何解决这个问题。
如果有人可以告诉我如何更正我的 Powershell sn-p 以便我可以创建一个虚拟目录?谢谢
【问题讨论】:
标签: powershell virtual-directory invoke-command appcmd