通过powershell停止默认网站

Jas*_* Li 2 powershell iis-7

我通过powershell停止默认网站,它已停止.但我发现重启后就开始了.

如果我在IIS7管理器中手动停止它,它将在重新启动机器后停止.

看起来像PowerShell停止网站效率不高.

有人对此有任何想法吗?

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

Kei*_*ill 7

当前状态和"启动"状态是两个不同的可控实体,就像它们在IIS管理器GUI中一样.将启动状态设置为手动或禁用,如下所示:

Set-Service w3svc -StartupType Manual
Run Code Online (Sandbox Code Playgroud)

更新:如果您只想影响多个站点上的启动,请尝试以下操作:

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
Run Code Online (Sandbox Code Playgroud)

  • 语法应该是Set-Service w3svc -StartupType手册.但这将阻止在PowerShell中启动网站. (2认同)