Share via


PowerShell Web Administration Module

Discussion

After a long time, we started discussing PowerShell and IIS. Yes, this is interesting for IIS admins and anyone who hosts sites in IIS.

How to start?

What version of PowerShell are you using? This is released in both 32-bit and 64-bit modules. Choose the appropriate one. 64-bit module will not work in 32-bit PowerShell.

How to Confirm PowerShell bit?

[intptr]::Size

If this returns 8 it's 64 bit and 4 denotes 32-bit version.

How to Load Module?

Import-Module WebAdministration -Verbose

Any error occurring please fix before proceeding. Note: Ensure Execution Policy is set to remote signed.

Few Web Admin Commands


Gets Web Site hosted in the machine


Get-Website

Gets Status of the machine


Get-Website | Select -Property Name , State

Gets Physical Physical Path of the Site


Get-Website | Select -Property Name , Physicalpath

Start Web Site


Start-Website -Name testdemo -Verbose

Stop Web Site


Stop-Website -Name TestDemo -Verbose

Remove Web Site


Remove-Website -Name 'TestDemo' -Verbose

Get-Website | Select -ExpandProperty bindings

Back-up WebSite Configuration


Backup-WebConfiguration -Name 'Default Web Site'

Restore Web Site Configuration


Restore-WebConfiguration -Name 'Default Web Site'

Explore More Commands


Get-Command -Module WebAdministration

Enjoy PowerShell :)