Chapter 23. IIS PowerShell cheat sheet

 

No one (including your author) knows what your particular PowerShell needs will be when working with IIS. Fortunately PowerShell is designed to be flexible. This chapter is a collection of my favorite PowerShell commands that I keep around. Each of these is explored elsewhere in this book, but here they are together for your reference. The list is always growing and changing, but this is a good start for your own cheat sheet.

Getting a list of IIS components

PS> Import-Module ServerManager #only required for PowerShell v2
PS> Get-WindowsFeature –Name *web*

Installing IIS

PS> Import-Module ServerManager #only required for PowerShell v2
PS> Add-WindowsFeature Web-Server

Testing a default installation

PS> Start iexplore http://<ServerName>

Importing and viewing cmdlets for IIS

PS> Import-Module WebAdministration
PS> Get-Command –Module WebAdministration
PS> Get-Command –noun web*
PS> Get-Help *web*

Viewing a website

PS> Get-WebSite –Name Default*
PS> Get-Childitem –Path iis:\sites
PS> Get-Childitem –Path c:\inetPub\wwwroot

Navigating to application pools

PS> Set-location IIS:\appPools
PS> Get-Childitem

Getting information about application pools

PS> Get-Item –Path IIS:\appPools\defaultAppPool
PS> Get-Item –Path IIS:\appPools\defaultAppPool | Format-List –Property *

Creating application pools

PS> New-WebAppPool –Name BikeTestPool

Changing a website to a new application pool

 
 
 
 

Getting a list of worker processes

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest