Reputation: 1975
I've done several Google searches and can't find a good sample to stop/start the 'Default Web Site' (in II6) using PowerShell.
This...
$server = "localhost"
$siteName = "default web site"
$iis = [ADSI]"IIS://$server/W3SVC"
$site = $iis.psbase.children | where { $_.keyType -eq "IIsWebServer"
-AND $_.ServerComment -eq $siteName }
from here got me started, but I can't get the 'start'/'stop' syntax right.
Upvotes: 5
Views: 3707
Reputation: 126932
Check the serverState property. A value of 2 means running and a value of 3 means stopped, you can set them this way:
$site.serverState = 2
$site.setInfo()
$site.serverState = 3
$site.setInfo()
Upvotes: 7
Reputation: 9497
http://www.microsoft.com/technet/scriptcenter/scripts/default.mspx?mfr=true. The example is in VBScript, but it's exactly the same technique in PowerShell.
Upvotes: 0
Reputation: 300817
Can you not use the Adsutil.vbs Administration Script (IIS 6.0)?
Upvotes: 0