温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

shall脚本-iis

发布时间:2020-08-10 03:54:27 来源:网络 阅读:266 作者:hcwj 栏目:网络安全

servermanagercmd -i Web-WebServer Web-Mgmt-Console Web-Scripting-Tools #安装IIS默认角色与管理控制台  
[system.reflection.assembly]::loadwithpartialname("Microsoft.Web.Administration") #调用dotnet Framework web管理程序集    
$sitename="benet"  #设置站点名称    
$sitepath="c:\benet" #设置站点的本地文件夹    
$siteip="192.168.10.40" #设置新建站点IP    
$vd="/prd" #定义虚拟目录名称    
$vdpath="c:\product" #定义虚拟目录的物理路径    
$web=new-object microsoft.web.administration.servermanager #新建web管理集servermanager对象    
$site=$web.sites #将服务器对象上的所有站点赋值给$site对象    
#对本地文件夹测试,如果不存在c:\benet文件夹,则创建    
if(!(test-path $sitepath))    
{    
New-Item $sitepath -itemtype directory    
}    
#新建一个站点,命名为benet,采用http访问协议,端口为80,主机名为www.benet.com    
$site.psbase.add($sitename,"http",$siteip+":80:www.benet.com",$sitepath)    
$web.commitchanges()    
#在benet站点上新建一个虚拟目录,命名为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()

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI