As with most areas of Windows Server 2008 and 2008 R2 , Microsoft is emphasizing PowerShell as an important tool for managing IIS 7 and IIS 7.5. The IIS PowerShell snap-in provides many new cmdlets and enables admins to manage IIS properties in numerous different ways.
Select Windows PowerShell Modules from the Administrative Tools group and the system will load the modules included with Windows Server 2008 , including the WebAdministration module which provides the IIS functionality. You may also import the module manually from the Windows PowerShell prompt using the below command:
Once the IIS PowerShell snap-in is running, you can display all the cmdlets it contains using the below command:
Get-Command –pssnapin WebAdministration
The IIS PowerShell snap-in uses three types of cmdlets:
- PowerShell provider cmdlets
- Task-oriented cmdlets
- Low-level configuration cmdlets
These cmdlet types relate to the three different methods of managing IIS from the PowerShell prompt.
Using the IIS PowerShell Provider
The IIS PowerShell provider creates a hierarchical IIS namespace which admins can navigate similar to a standard directory structure. Type iis: and press Enter at the PowerShell prompt (with the WebAdministration module having been already imported) and the prompt changes to PS IIS:> then typing the dir command displays, but the top level of the IIS namespace (not the file system) as below:
Name ---- AppPools Sites SslBindings
After moving to the Sites directory using the cd Sites command, the dir command displays a list of the IIS sites on the server.
The Get-Item cmdlet allows you to show selected sites in the same format. By piping results of the Get-Item cmdlet to the Select-Object cmdlet, you can see all properties of a selected site.