How can I stop and start individual websites in IIS using PowerShell? How can I stop and start individual websites in IIS using PowerShell? powershell powershell

How can I stop and start individual websites in IIS using PowerShell?


Just for future quick reference, the commands are:

Import-Module WebAdministrationStop-WebSite 'Default Web Site'Start-WebSite 'Default Web Site'


Adding to Keith's answer, you can perform this remotely using Invoke-Command.

Import-Module WebAdministration$siteName = "Default Web Site"$serverName = "name"$block = {Stop-WebSite $args[0]; Start-WebSite $args[0]};  $session = New-PSSession -ComputerName $serverNameInvoke-Command -Session $session -ScriptBlock $block -ArgumentList $siteName 


To get access to system modules, Powershell needs to be run like this:

[path]\powershell.exe -NoExit -ImportSystemModules

I found the above on this iis forum.