我正在尝试创建一个PowerShell脚本,创建一个新的IIS 6网站,并设置应用程序池,通配符应用程序映射,ASP.NET版本等.
在Internet上进行了大量搜索之后,我发现了一个脚本,它允许我创建一个新的Web站点,但不能修改我需要的所有属性.
$newWebsiteName = "WebSiteName"
$newWebsiteIpAddress = "192.168.1.100"
$newWebSiteDirPath = "c:\inetpub\wwwroot\WebSiteName"
$iisWebService = Get-WmiObject -namespace "root\MicrosoftIISv2"
-class "IIsWebService"
$bindingClass = [wmiclass]'root\MicrosoftIISv2:ServerBinding'
$bindings = $bindingClass.CreateInstance()
$bindings.IP = $newWebsiteIpAddress
$bindings.Port = "80"
$bindings.Hostname = ""
$result = $iisWebService.CreateNewSite
($newWebsiteName, $bindings, $newWebSiteDirPath)
Run Code Online (Sandbox Code Playgroud)
任何有关如何扩展上述示例的帮助非常感谢.