简体   繁体   English

通过 powershell 停止默认 web 站点

[英]Stop default web site by powershell

I stop default web site by powershell and it's stopped.我通过 powershell 停止默认的 web 站点并且它停止了。 But I find it started after reboot.但我发现它在重新启动后开始。

If I stop it manually in IIS7 manager, it will be stopped after rebooting machine.如果我在 IIS7 管理器中手动停止它,它将在重新启动机器后停止。

It looks like stopping website by powershell is not so efficient.看起来通过 powershell 停止网站并不是那么有效。

anybody has any idea about it?有人对此有任何想法吗?

OS: Windows 2008 R2 SP1 IIS: 7操作系统:Windows 2008 R2 SP1 IIS:7

The current state and the "startup" state are two different controllable entities just as they are in the IIS Manager GUI.当前的 state 和“启动” state 是两个不同的可控实体,就像它们在 IIS 管理器 GUI 中一样。 Set the startup state to Manual or Disabled like so:将启动 state 设置为 Manual 或 Disabled,如下所示:

Set-Service w3svc -StartupType Manual

Update: If you only want to affect the startup of one on several sites then try this:更新:如果您只想影响多个站点上的一个启动,请尝试以下操作:

PS> ipmo WebAdministration
PS> Get-ItemProperty 'IIS:\Sites\Default Web Site' ServerAutoStart


PSPath                      : WebAdministration::\\HILLR1\Sites\Default Web Site
PSParentPath                : WebAdministration::\\HILLR1\Sites
PSChildName                 : Default Web Site
PSDrive                     : IIS
PSProvider                  : WebAdministration
IsInheritedFromDefaultValue : False
IsProtected                 : False
Name                        : serverAutoStart
TypeName                    : System.Boolean
Schema                      : Microsoft.IIs.PowerShell.Framework.ConfigurationAttributeSchema
Value                       : True
IsExtended                  : False

PS> Set-ItemProperty 'IIS:\Sites\Default Web Site' ServerAutoStart False

If you are trying to do this on Server 2012R2 ServerAutoStart is serverAutoStart (notice the lowercase "s" in serverAutoStart如果您尝试在 Server 2012R2 ServerAutoStart 上执行此操作,则为 serverAutoStart(注意 serverAutoStart 中的小写“s”

Hooray for case sensitivity:)万岁区分大小写:)

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

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