我们如何处理网站名称中的空白区域

时间:2013-05-28 10:06:25

标签: powershell command

我的要求是将一个Web应用程序添加到默认网站并启用目录浏览。 我正在使用以下命令行来创建应用程序。

 C:\Windows\System32\inetsrv> .\appcmd.exe add app /site.name:"mytest" /Path=/test4 /PhysicalPath:"c:\test

这工作正常。但是如果我尝试将网站名称设置如下:

C:\Windows\System32\inetsrv> .\appcmd.exe add app /site.name:"Default Web Site" /Path=/test4 /PhysicalPath:"c:\test

它给出了错误。请帮助:)

1 个答案:

答案 0 :(得分:0)

由于此问题已使用Powershell标记,因此这是使用WebAdministration模块的PowerShell解决方案:

Import-Module webadministration

# Create the Web Application
New-WebApplication -Name testApp -Site 'Default Web Site' -PhysicalPath c:\test -ApplicationPool DefaultAppPool

# Set directory browsing enabled
Set-WebConfigurationProperty -filter /system.webServer/directoryBrowse -name enabled -PSPath 'IIS:\Sites\Default Web Site' -Value $true