Author Posts

January 1, 2012 at 12:00 am

by PDKing at 2013-01-28 12:49:34

I am having an issue where ASP4 is creating new AppPools for any that are not using ASP4 and reassigning any sites to the new AppPool. I have a PS script to reassign all these back to their original settings and have been trying to build a script to check the AppPools and email out the results.

I can run this (dir IIS:\AppPools\'ASP.NET v4.0*') in ISE on the servers and it returns the data I'm looking for. How can I get this information into the body of an email for PS to send without wrecking the formatting?

Also, one of the secondary things I'd like to do is only return AppPools that have Applications assigned to them.

Example data returned (the red line is the only one with a site "Internet Product" assigned):

Name State Applications
—- —– ————
ASP.NET v4.0 Started
ASP.NET v4.0 ASP.NET 1.1 Started
ASP.NET v4.0 ASP2.0AppPo Started
ol
ASP.NET v4.0 Classic Started
ASP.NET v4.0 DefaultAppP Started Internet Product
ool

ASP.NET v4.0 eDocuments Started
ASP.NET v4.0 SitesFromCM Started
V
ASP.NET v4.0 SwsCB Started

by JasonHelmick at 2013-01-28 13:37:01

Hey PDKing!

I don;t have IIS in front of me, but try something like this —

Find the app pools you want, then save the properties as an html file.

PS> dir iid:\Sites | Where-Object {$_.ApplicationPool -like "*v4.0*"} | Select-Object -Property Name, State, ApplicationPool |
ConvertTo-HTML | Out-File c:\whatever.htm

Then send a message using Send-MailMessage with the HTML file.

PS>Send-MailMessage -To Me@nowhere.com -From Me@Nowhere.com -Subject "Subject goes here..." -Attachment c:\whatever.htm
-SMTPServer your.smtp.server

Does this help?

Jason

by PDKing at 2013-01-28 14:11:06

The convert seem to jumble up some of the data, but it did find the Site.

Is there a similar command to find the virtual directories and applications that are under the site?

by JasonHelmick at 2013-02-07 07:51:04

Hmmm....how about something like this....

$sites=Get-childitem -Path iis:\sites\* | where{$_.applicationPool -like "*v4*"}
Get-ChildItem -path ($sites.pspath) | where{$_.NodeType -like "app*" -or $_.NodeType -like "Virtual*"} | select-Object -Property Name, ApplicationPool, nodetype

How's that?