简体   繁体   English

使用PowerShell在IIS6中停止“默认网站”

[英]Use PowerShell to stop 'Default Web Site' in IIS6

I've done several Google searches and can't find a good sample to stop/start the 'Default Web Site' (in II6) using PowerShell. 我已经完成了几次Google搜索,找不到使用PowerShell停止/启动“默认网站”(在II6中)的好示例。

This... 这个...

$server = "localhost"
$siteName = "default web site"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer" 
        -AND $_.ServerComment -eq $siteName }

from here got me started, but I can't get the 'start'/'stop' syntax right. 这里开始,但我不能正确地使用'start'/'stop'语法。

Check the serverState property. 检查serverState属性。 A value of 2 means running and a value of 3 means stopped, you can set them this way: 值2表示正在运行,值3表示停止,您可以这样设置它们:

start the website 启动网站

$site.serverState = 2 $ site.serverState = 2

$site.setInfo() $ site.setInfo()

stop the website 停止网站

$site.serverState = 3 $ site.serverState = 3

$site.setInfo() $ site.setInfo()

你能不能使用Adsutil.vbs管理脚本(IIS 6.0)

http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true . http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true The example is in VBScript, but it's exactly the same technique in PowerShell. 该示例在VBScript中,但它与PowerShell中的技术完全相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM