Starting and Stopping Web Sites

There are times when a Web site must be either stopped or started. You might stop a Web site for maintenance or for security reasons. It is obvious why a Web site needs to be started: A Web site that is not running is useless as a Web site! To stop or start a Web site, use the WMI classes supplied by the IIS 7 WMI provider.

The StartStopSite.ps1 script is an example of a script that can be used to start and stop Web sites. It begins with the param statement and defines a number of parameters. The -site parameter names the Web site to be either stopped or started. The other parameters are optional. The -start parameter is a switched parameter and, if present, causes the script to start the Web site. The -stop parameter ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.