为 IIS 7 编写远程控制脚本

发布于 2024-09-19 09:13:54 字数 835 浏览 3 评论 0原文

我的服务器运行在 Windows Server 2008、IIS 7 上。
我的客户端是Windows Server 2003或Windows XP。

我想远程启动/停止网站。
我轻松地在客户端计算机上使用 IIS 7 管理器以交互方式完成此操作(参见 http://blogs.iis.net/bdela/archive/2007/10/08/remote-administration-managing -iis-7-rco-from-windows-xp-2k3-and-vista.aspx

但我想以非交互方式来完成它,目标是编写脚本这是 msbuild 脚本的一部分。

我尝试了 MSBuildExtensionPack,但只有在客户端站点上安装了 IIS7 时它才有效。 我尝试了 powershell cmdlet,但我必须在服务器上启动 dcom (http://learn.iis.net/page.aspx/160/writing-powershell-commandlets-for-iis-70/)。

我能做些什么?

My server is running on windows server 2008, IIS 7.
My client is Windows server 2003 or Windows XP.

I want to start/stop websites remotely.
I easily managed to do it interactively using IIS 7 manager on my clients machines (cf http://blogs.iis.net/bdela/archive/2007/10/08/remote-administration-managing-iis-7-rco-from-windows-xp-2k3-and-vista.aspx )

But I want to do it in a non interactive-way, the goal is to script this as part of a msbuild script.

I tried the MSBuildExtensionPack but it works only if IIS7 is installed on the client site.
I tried powershell cmdlets, but I have to start dcom on the server (http://learn.iis.net/page.aspx/160/writing-powershell-commandlets-for-iis-70/ ).

What can I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海蓝天 2024-09-26 09:13:55

如果您可以将客户端和服务器都升级到 PowerShell 2.0,则可以使用 PowerShell 远程处理以及 PowerShell 2.0 的 Web 管理模块来执行此操作。首先,您需要在服务器 PowerShell 上启用远程处理,如下所示(通过提升的提示符):

PS> Set-ExecutionPolicy RemoteSigned
PS> Enable-PSRemoting -Force

然后在客户端计算机上执行以下命令:

PS> Invoke-Command servername {Import-Module WebAdministration; Stop-WebSite Foo}

If you can upgrade both client and server to PowerShell 2.0 you could use PowerShell remoting along with PowerShell 2.0's WebAdministration module to do this. First you need to enable remoting on the server PowerShell like so (from an elevated prompt):

PS> Set-ExecutionPolicy RemoteSigned
PS> Enable-PSRemoting -Force

Then on the client machine execute the following:

PS> Invoke-Command servername {Import-Module WebAdministration; Stop-WebSite Foo}
帅气称霸 2024-09-26 09:13:55

谢谢! Powershell 2.0 成功了。然而你的命令似乎不起作用。

在服务器端我运行

PS> winrm quickconfig

,在客户端我运行

PS> Invoke-Command -computername servername -scriptblock {[system.reflection.assembly]::loadfrom("c:\windows\system32\inetsrv\microsoft.web.administration.dll");$server2 = New-object microsoft.web.administration.servermanager;$server2.Sites["Foo"].Stop()}

如所述: http://www.powershellcommunity.org/Default.aspx?tabid=55&EntryID=65

Thanks! Powershell 2.0 did the trick. Nevertheless your commands didn't seem to work.

On the server side I ran

PS> winrm quickconfig

and on the client side I ran

PS> Invoke-Command -computername servername -scriptblock {[system.reflection.assembly]::loadfrom("c:\windows\system32\inetsrv\microsoft.web.administration.dll");$server2 = New-object microsoft.web.administration.servermanager;$server2.Sites["Foo"].Stop()}

As described in : http://www.powershellcommunity.org/Default.aspx?tabid=55&EntryID=65

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文