您好,登錄后才能下訂單哦!
servermanagercmd -i Web-WebServer Web-Mgmt-Console Web-Scripting-Tools #安裝IIS默認(rèn)角色與管理控制臺(tái)
[system.reflection.assembly]::loadwithpartialname("Microsoft.Web.Administration") #調(diào)用dotnet Framework web管理程序集
$sitename="benet" #設(shè)置站點(diǎn)名稱
$sitepath="c:\benet" #設(shè)置站點(diǎn)的本地文件夾
$siteip="192.168.10.40" #設(shè)置新建站點(diǎn)IP
$vd="/prd" #定義虛擬目錄名稱
$vdpath="c:\product" #定義虛擬目錄的物理路徑
$web=new-object microsoft.web.administration.servermanager #新建web管理集servermanager對(duì)象
$site=$web.sites #將服務(wù)器對(duì)象上的所有站點(diǎn)賦值給$site對(duì)象
#對(duì)本地文件夾測(cè)試,如果不存在c:\benet文件夾,則創(chuàng)建
if(!(test-path $sitepath))
{
New-Item $sitepath -itemtype directory
}
#新建一個(gè)站點(diǎn),命名為benet,采用http訪問(wèn)協(xié)議,端口為80,主機(jī)名為www.benet.com
$site.psbase.add($sitename,"http",$siteip+":80:www.benet.com",$sitepath)
$web.commitchanges()
#在benet站點(diǎn)上新建一個(gè)虛擬目錄,命名為prd,物理路徑為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()
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。