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

Powershell 我们如何处理网站名称中的空白,powershell,command,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:"Defau

我的要求是在默认网站中添加一个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

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

由于此问题已被标记为Powershell,下面是一个使用模块的Powershell解决方案:


您遇到的错误是什么?:此命令用于创建web应用程序,我已经使用过它,但我无法使用powershell在web应用程序上设置目录浏览,由于这个原因,我转到命令行,在那里遇到了空白的问题。如果有办法在web应用程序上的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