tags:

views:

44

answers:

1

I have multiple servers that need to have the IISADMIN service restarted. I need to do this remotely, so I have code that will ask for credentials. however when I get to the point of stopping it and restarting it, it fails because the dependant services. I am trying to use IISRESET /STOP, but cannot get it to function.

Any suggestions would be greatly appreciated. if you need to see the code let me know.

Thanks!

+1  A: 

If you have PowerShell 2.0 available I would use its remoting capabilities. You also have to admin to use iisreset (at least on Vista/WinServer 2008 and above). Fortunately PowerShell remoting takes care of that (requires you to be admin too). :-) With PowerShell 2.0 I would try something like this:

$cred = Get-Credential
Invoke-Command server1,server2,server3 -ScriptBlock { iisreset.exe /restart } `
               -cred $cred

If the iisreset.exe still isn't working try PowerShell's Restart-Service in its place:

Restart-Service w3svc -Force

But first you have to have PowerShell 2.0 on each remote machine and enable remoting on each remote machine via the commands:

Set-ExecutionPolicy RemoteSigned
Enable-PSRemoting -Force

If you can't do PowerShell 2.0 on the remote machines, you could always use psexec.exe.

Keith Hill