Shall script-iis
Servermanagercmd-I Web-WebServer Web-Mgmt-Console Web-Scripting-Tools # installs the IIS default role and administrative console
[system.reflection.assembly]:: loadwithpartialname ("Microsoft.Web.Administration") # call dotnet Framework web management assembly
$sitename= "benet" # set the site name
$sitepath= "c:\ benet" # set the local folder of the site
$siteip= "192.168.10.40" # set up the new site IP
$vd= "/ prd" # defines the virtual directory name
$vdpath= "c:\ product" # defines the physical path to the virtual directory
$web=new-object microsoft.web.administration.servermanager # New web Management set servermanager object
$site=$web.sites # assigns all sites on the server object to the $site object
# Test the local folder, and if the c:\ benet folder does not exist, create
If (! (test-path $sitepath))
{
New-Item $sitepath-itemtype directory
}
# create a new site named benet, using http access protocol, port 80, and hostname www.benet.com
$site.psbase.add ($sitename, "http", $siteip+ ": 80:www.benet.com", $sitepath)
$web.commitchanges ()
# create a new virtual directory on the benet site, named prd, and the physical path is c:\ product
$web=new-object microsoft.web.administration.servermanager
$site=$web.sites |? {$_ .name-eq $sitename}
$app=$site.Applications |? {$_ .ApplicationPoolName-eq "DefaultAppPool"}
If (! (test-path $vdpath))
{
New-Item $vdpath-ItemType directory
}
$app.VirtualDirectories.add ($vd,$vdpath)
$web.commitchanges ()