【问题标题】:Powershell List of WebSites and the removal of sites in "Stopped" statePowershell 网站列表和删除处于“已停止”状态的网站
【发布时间】:2015-01-14 17:47:32
【问题描述】:

我正在寻找一种方法来删除所有处于“已停止”状态的 IIS 站点。有人可以给我看一个 powershell 脚本吗?

Get-Website | select name,id,state

上面列出了网站,网站的ID和状态我一直无法弄清楚的是如何只列出State=Stopped以及如何根据state=Stopped使用Remove-Website

下面的命令没有输出,也没有错误;

Get-Website | Where-Object {$_.status -eq "Stopped"}

我很快就点击了发布按钮,谢谢...

谢谢!

【问题讨论】:

  • SO 不是代码编写服务,如果您有代码要展示,我们很乐意为您提供帮助。否则你在错误的网站上

标签: powershell iis-7 iis-7.5


【解决方案1】:

这应该为您提供所有状态为“已停止”的网站:

Get-Website | where {$_.state -eq "Stopped" }

由于我没有任何要删除的网站,因此以下内容未经测试,但应该适用于删除任务:

Get-Website | where {$_.state -eq "Stopped" } | Remove-Website

【讨论】:

  • Paul,这两个脚本都完全按照需要工作。非常感谢先生。
猜你喜欢
  • 2013-06-20
  • 2010-09-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-30
相关资源
最近更新 更多