How can I find the total number of sites hosted in an instance of IIS 7? It doesn't matter if it is in PowerShell, I just can't seem to find some trival way to find this information...
2 Answers
Use appcmd.
Open cmd and execute:
- For 32 Bits
C:\Windows\System32\inetsrv\appcmd list site > C:\temp\websites.txt
- For 64 Bits
C:\Windows\SysWOW64\inetsrv\appcmd list site > C:\temp\websites.txt
Your ouput file will have a full description of all sites in IIS 7.
Open the file with some text editor with line numbers, or use excel and take a look on total rows.
The appcmd mentioned previously is pretty cool. But if you start Powershell and type:
get-website
You'll get a pretty listing of all the configured websites and bindings:
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Default Web Site 1 Stopped %SystemDrive%\inetpub\wwwroot http *:80:
net.tcp 808:*
net.pipe *
net.msmq localhost
msmq.formatname localhost
You might need to add the IIS WebManagement snapin. But if you start Powershell from the Administrative Tools
folder, it'll have the snapin already loaded.