Now that you have the Windows PowerShell Snap-in for IIS 7.0 loaded (how-to posted here), let’s navigate IIS to see what we can find.
First, you need to switch over to the IIS namespace in order to display information much like you would in IIS Manager. Type “cd IIS:\“, then type “dir“. You should now see the top level structure of IIS. Now type, “cd AppPools“, then type “dir“. You now see a list of your Application Pool names, the status, and the associated application(s) with each app pool. The screenshot below depicts the actions you just took (I have SP2010 installed on this machine):
Next, we’ll move up a directory and drill into Sites. Type “cd..“, then “cd Sites“, and “dir” – just like you would in DOS. Looking into this we quickly get the name, ID, state, physical path, and a list of bindings for each site on our server – pretty cool, eh?
Lastly, use the Get-Item command in conjunction with Select-Object to display the configuration settings for one of the sites. Type “Get-Item <Site Name> | Select-Object *“. View the below screenshot as an example:
You could use this same approach for one of the Application Pools too – just make sure you navigate back to IIS:\AppPools before running the command. The next posts regarding IIS and PowerShell will focus more on task based functions you can do, as well as backing up your configuration settings. So, check back soon!
03/22/2010
PowerShell