Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Shall script-iis

Shulou Source: shulou.com Published: 2022-06-01 02:27:56 09月30日 Update

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 ()

Tags: Site object file folder directory administration name physics path host console server program port role control service test script Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn Shulou Tech Info NVidia Xiaomi