使用Powershell或命令行启动/停止应用程序池IIS6.0
我正在使用 IIS 6.0 并寻找一种停止/启动应用程序池的方法。我知道7.0中有一个用于powershell的stop-appPool,但使用的是6.0。 :-( 那么有人有一个 powershell 脚本或另一个命令行 exe 可以停止/启动应用程序池吗?
谢谢。
I'm using IIS 6.0 and looking for a way to stop/start the app pool. I know there is a stop-appPool for powershell in 7.0 but using 6.0. :-( So does anyone have a powershell script or another command line exe that will stop/start the app pool?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好的,就是这样,我只是添加一个开关来停止应用程序池,否则它会启动,因为启动已经启动的应用程序池没有任何害处:
Ok here it is, I just add a switch to stop the app pool else it starts since no harm in starting an app pool that is already started:
如果有人正在寻找不需要 Powershell 的纯命令行工具,我已经创建了这样一个东西 基于这些其他答案中包含的信息。由于最初的问题是专门寻找可能的命令行替代方案,因此我想我会在这里分享它。
用法非常简单:
来源和二进制文件 可在 bitbucket 上获取。也许这可以让其他人免去几分钟的苦恼。
If anybody is looking for a purely command-line tool that does not require Powershell, I have created such a thing based on the information contained in these other answers. Since the original question is specifically looking for possible command-line alternatives, I thought I would share it here.
Usage is quite simple:
Source and binaries are available on bitbucket. May this save somebody else a few minutes of head scratching.
您可能对我开始维护的这个 Powershell 库感兴趣:
psDeploy:http:// rprieto.github.com/psDeploy/
除此之外,它还有许多用于 IIS6 自动化的 cmdlet,例如 Start-IIS6AppPool、New-IIS6Website...
我希望它有帮助!
You might be interested in this Powershell library I started maintaining:
psDeploy : http://rprieto.github.com/psDeploy/
Among other things it has lots of cmdlets for IIS6 automation, for example Start-IIS6AppPool, New-IIS6Website...
I hope it helps!
如果在 Windows Server 2003 上,使用提供的脚本会更简单 iisapp.vbs
或者根据您的设置(默认为 Cscript 而不是 WScript),简单
当然它在 IIS7
If on Windows Server 2003 it is simpler to use the supplied script iisapp.vbs
Or depending on your setup (default to Cscript not WScript), simply
And of course it is different in IIS7
如果您希望远程执行此操作,和/或在没有 powershell 的计算机上执行此操作,您可以修改 此处发布的脚本。
它使用 WMI 从 VBScript 访问和回收应用程序池。使其停止/启动池而不是回收它们是一个微不足道的更改,您只需在相关应用程序池上调用
.Stop
或.Start
即可。该脚本的主要内容解释如下:
如果您有某种命令行/批处理工具链,并且想要将其集成到其中,则可以通过调用以下命令在命令行模式下执行 VBScript 文件:
\NoLogo 开关删除 VBScript 解释器启动消息并使用 CScript.exe 运行它意味着对
WScript.Echo
的调用将转到命令行而不是弹出窗口。If you wish to do this remotely, and / or on a machine without powershell you can modify the script posted here.
It uses WMI to access and recycle the app pool, from VBScript. It's a trivial change to make it stop / start pools instead of recycling them, you just need to call
.Stop
or.Start
on the app pool in question.The meat of the script is paraphrased below:
If you have some kind of command line / batch toolchain which you want to integrate this into, you can execute a VBScript file in command line mode by calling:
The \NoLogo switch removes the VBScript interpreter startup messages and running it with CScript.exe means that calls to
WScript.Echo
go to the command line rather than a popup window.您可以创建一个函数来远程停止或启动应用程序池,如下所示:
You could create a function to stop or start the application pool remotely as below: