views:

41

answers:

2

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?

A: 

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:

PS> Invoke-Command servername {Import-Moule WebAdministration; Stop-WebSite Foo}
Keith Hill
A: 

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

Benjamin Baumann