IIS WMI Script Help!

IIS WMI Script Help!

am 20.11.2007 18:24:20 von Spitfire

Hi,

This is my first wmi script. I am trying to list all the Applications and
associated ( Application Pools & .Net Version) .

What works and not:
I can print Application Name and AppPool but I could not figure out how to
retrive .Net version. I checked the API at
http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is not as
simple as I am trying.


Why I want this script ?:
Because there are hundreds of web applications running in my IIS server and
I think there is one or more "application pool" that has more than 1
version (v 1.7 and v 2.0 ) of .Net application associated with it. I am not
sure exactly, but somewhere I read it can be a problem if you have more than
1 version of .Net application running in same appPool.

-------
var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
IIsWebDirectorySetting";
var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
var sites = providerObj.ExecQuery(query);


if ( sites.Count != 0 )
{
for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
var item = e.item();
//print information
WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
}
}
else {
WScript.Echo("No Sites Found");
}


----------

thanks in advance :)

Re: IIS WMI Script Help!

am 20.11.2007 18:52:50 von Kristofer Gafvert

Hi,

AspScriptLanguage has nothing to do with ASP.NET. You need to use the
ScriptMaps property to figure out the version of ASP.NET the application
is using.

If I understand your task correctly, this script will do exactly what you
want to do:

http://blog.crowe.co.nz/archive/2006/08/15/676.aspx

It does however not use WMI...


--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info


spitfire wrote:

>Hi,
>
>This is my first wmi script. I am trying to list all the Applications and
>associated ( Application Pools & .Net Version) .
>
>What works and not:
>I can print Application Name and AppPool but I could not figure out how to
>retrive .Net version. I checked the API at
>http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is not
>as simple as I am trying.
>
>
>Why I want this script ?:
>Because there are hundreds of web applications running in my IIS server
>and I think there is one or more "application pool" that has more than 1
>version (v 1.7 and v 2.0 ) of .Net application associated with it. I am
>not sure exactly, but somewhere I read it can be a problem if you have
>more than 1 version of .Net application running in same appPool.
>
>-------
>var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
>IIsWebDirectorySetting";
>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>var sites = providerObj.ExecQuery(query);
>
>
>if ( sites.Count != 0 )
>{
>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
> var item = e.item();
>//print information
> WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
>}
>}
>else {
>WScript.Echo("No Sites Found");
>}
>
>
>----------
>
>thanks in advance :)

Re: IIS WMI Script Help!

am 20.11.2007 22:06:21 von Spitfire

I have been trying to print "ScriptMaps". I think it is an array. But I am
not able to print its content. I would be glad if someone could help me on
that.


Yes the script does the same thing that I am looking for but I get an error:

C:\Documents and Settings\b.n.admin\Desktop>cscript app_pool_check.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

AppPool #1
C:\Documents and Settings\b.n.admin\Desktop\app_pool_check.vbs(43, 4)
Microsoft
VBScript runtime error: Object doesn't support this property or method:
'ScriptM
aps'

thanks



"Kristofer Gafvert" wrote in message
news:xn0fdxfo7x8t93i01r@news.microsoft.com...
> Hi,
>
> AspScriptLanguage has nothing to do with ASP.NET. You need to use the
> ScriptMaps property to figure out the version of ASP.NET the application
> is using.
>
> If I understand your task correctly, this script will do exactly what you
> want to do:
>
> http://blog.crowe.co.nz/archive/2006/08/15/676.aspx
>
> It does however not use WMI...
>
>
> --
> Regards,
> Kristofer Gafvert
> http://www.gafvert.info/iis/ - IIS Related Info
>
>
> spitfire wrote:
>
>>Hi,
>>
>>This is my first wmi script. I am trying to list all the Applications and
>>associated ( Application Pools & .Net Version) .
>>
>>What works and not:
>>I can print Application Name and AppPool but I could not figure out how to
>>retrive .Net version. I checked the API at
>>http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is not
>>as simple as I am trying.
>>
>>
>>Why I want this script ?:
>>Because there are hundreds of web applications running in my IIS server
>>and I think there is one or more "application pool" that has more than 1
>>version (v 1.7 and v 2.0 ) of .Net application associated with it. I am
>>not sure exactly, but somewhere I read it can be a problem if you have
>>more than 1 version of .Net application running in same appPool.
>>
>>-------
>>var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
>>IIsWebDirectorySetting";
>>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>>var sites = providerObj.ExecQuery(query);
>>
>>
>>if ( sites.Count != 0 )
>>{
>>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
>> var item = e.item();
>>//print information
>> WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
>>}
>>}
>>else {
>>WScript.Echo("No Sites Found");
>>}
>>
>>
>>----------
>>
>>thanks in advance :)

Re: IIS WMI Script Help!

am 20.11.2007 22:16:45 von Spitfire

This is what I have tried:

------------

var query = "SELECT AppPoolId, AppFriendlyName, ScriptMaps FROM
IIsWebDirectorySetting";
var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
var sites = providerObj.ExecQuery(query);
var i = 0;

if ( sites.Count != 0 )
{
for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
var item = e.item();
WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID + "
AAA: " + item.ScriptMaps);

//seems ScriptMaps is Empty
for ( ScriptMap in item.ScriptMaps ) {
WScript.Echo("val is: " + ScriptMap);
}

}
}
else {
WScript.Echo("No Sites Found");
}



"Kristofer Gafvert" wrote in message
news:xn0fdxfo7x8t93i01r@news.microsoft.com...
> Hi,
>
> AspScriptLanguage has nothing to do with ASP.NET. You need to use the
> ScriptMaps property to figure out the version of ASP.NET the application
> is using.
>
> If I understand your task correctly, this script will do exactly what you
> want to do:
>
> http://blog.crowe.co.nz/archive/2006/08/15/676.aspx
>
> It does however not use WMI...
>
>
> --
> Regards,
> Kristofer Gafvert
> http://www.gafvert.info/iis/ - IIS Related Info
>
>
> spitfire wrote:
>
>>Hi,
>>
>>This is my first wmi script. I am trying to list all the Applications and
>>associated ( Application Pools & .Net Version) .
>>
>>What works and not:
>>I can print Application Name and AppPool but I could not figure out how to
>>retrive .Net version. I checked the API at
>>http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is not
>>as simple as I am trying.
>>
>>
>>Why I want this script ?:
>>Because there are hundreds of web applications running in my IIS server
>>and I think there is one or more "application pool" that has more than 1
>>version (v 1.7 and v 2.0 ) of .Net application associated with it. I am
>>not sure exactly, but somewhere I read it can be a problem if you have
>>more than 1 version of .Net application running in same appPool.
>>
>>-------
>>var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
>>IIsWebDirectorySetting";
>>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>>var sites = providerObj.ExecQuery(query);
>>
>>
>>if ( sites.Count != 0 )
>>{
>>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
>> var item = e.item();
>>//print information
>> WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
>>}
>>}
>>else {
>>WScript.Echo("No Sites Found");
>>}
>>
>>
>>----------
>>
>>thanks in advance :)

Re: IIS WMI Script Help!

am 21.11.2007 15:35:32 von Kristofer Gafvert

Hi,

I am currently moving to a new computer, so i could only find this example
in vbs. But i think it should give you the necessary information to
implement this in js. Do note how I enumerate the ScriptMaps property.

Also see (I only use Extensions and ScriptProcessor, there is also Flags
and IncludedVerbs):
http://msdn2.microsoft.com/en-us/library/ms526052.aspx


strComputer = "."
Set objWMIService = GetObject _
("winmgmts:{authenticationLevel=pktPrivacy}\\" _
& strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
("Select * from IIsWebDirectorySetting")

For Each objItem in colItems
WScript.Echo( " App: " + objItem.AppFriendlyName)

For i = 0 to Ubound(objItem.ScriptMaps)
Wscript.Echo "Extension: " & _
objItem.ScriptMaps(i).Extensions
Wscript.Echo "Executable: " & _
objItem.ScriptMaps(i).ScriptProcessor
Next
Next


--
Regards,
Kristofer Gafvert
http://www.gafvert.info/iis/ - IIS Related Info


spitfire wrote:

>This is what I have tried:
>
>------------
>
>var query = "SELECT AppPoolId, AppFriendlyName, ScriptMaps FROM
>IIsWebDirectorySetting";
>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>var sites = providerObj.ExecQuery(query);
>var i = 0;
>
>if ( sites.Count != 0 )
>{
>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
> var item = e.item();
>WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID + "
>AAA: " + item.ScriptMaps);
>
> //seems ScriptMaps is Empty
> for ( ScriptMap in item.ScriptMaps ) {
> WScript.Echo("val is: " + ScriptMap);
> }
>
>}
>}
>else {
>WScript.Echo("No Sites Found");
>}
>
>
>
>"Kristofer Gafvert" wrote in message
>news:xn0fdxfo7x8t93i01r@news.microsoft.com...
>>Hi,
>>
>>AspScriptLanguage has nothing to do with ASP.NET. You need to use the
>>ScriptMaps property to figure out the version of ASP.NET the application
>>is using.
>>
>>If I understand your task correctly, this script will do exactly what you
>>want to do:
>>
>>http://blog.crowe.co.nz/archive/2006/08/15/676.aspx
>>
>>It does however not use WMI...
>>
>>
>>-- Regards,
>>Kristofer Gafvert
>>http://www.gafvert.info/iis/ - IIS Related Info
>>
>>
>>spitfire wrote:
>>
>>>Hi,
>>>
>>>This is my first wmi script. I am trying to list all the Applications and
>>>associated ( Application Pools & .Net Version) .
>>>
>>>What works and not:
>>>I can print Application Name and AppPool but I could not figure out how to
>>>retrive .Net version. I checked the API at
>>>http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is not
>>>as simple as I am trying.
>>>
>>>
>>>Why I want this script ?:
>>>Because there are hundreds of web applications running in my IIS server
>>>and I think there is one or more "application pool" that has more than 1
>>>version (v 1.7 and v 2.0 ) of .Net application associated with it. I am
>>>not sure exactly, but somewhere I read it can be a problem if you have
>>>more than 1 version of .Net application running in same appPool.
>>>
>>>-------
>>>var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
>>>IIsWebDirectorySetting";
>>>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>>>var sites = providerObj.ExecQuery(query);
>>>
>>>
>>>if ( sites.Count != 0 )
>>>{
>>>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
>>>var item = e.item();
>>>//print information
>>>WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
>>>}
>>>}
>>>else {
>>>WScript.Echo("No Sites Found");
>>>}
>>>
>>>
>>>----------
>>>
>>>thanks in advance :)

Re: IIS WMI Script Help!

am 21.11.2007 15:57:23 von Spitfire

Thanks, Now I know where I made mistake.

Also, modified a script and make it work like I wanted:

Set objAppPools = GetObject("IIS://localhost/W3SVC/AppPools")
for each objAppPool in objAppPools
Redim Versions(0)
Set objAppPool = GetObject("IIS://localhost/W3SVC/AppPools/" &
objAppPool.Name )
' WScript.echo objAppPool.Name
AppsInPool= objAppPool.EnumAppsInPool()
if (ubound(AppsInPool) = -1) then
WScript.echo vbtab & "No applications using this pool!"
else
for index = lbound(AppsInPool) to UBound(AppsInPool)
'for each appPool
IISPath = AppsInPool(index)
'WScript.echo "IISPATH: " & IISPath
IISPath = "IIS://localhost/" & mid(IISPath,5, len(IISPath)-5)
set IISObj = GetObject(IISPath)
Dim pos, ScriptMap, MapVer
if ( IISObj.Name = "ROOT" ) then
'WScript.echo objAppPool.Name
'WScript.echo "Search Path: " & IISPath
'WScript.Echo IISObj.Name

for each ScriptMap in IISObj.ScriptMaps
'WScript.Echo ScriptMap
if (left(ScriptMap, 5) = ".aspx") then
MapVer = mid(ScriptMap, 42)
MapVer = left(MapVer, instr(MapVer, "\")-1)
'WScript.echo MapVer
'WScript.Echo "--------------------------------------------"

WSCript.Echo objAppPool.Name & " " & IISPath & " " & MapVer
end if
next
end if
next
end if
WScript.echo ""
next

"Kristofer Gafvert" wrote in message
news:xn0fdyp2nyh7fud01t@news.microsoft.com...
> Hi,
>
> I am currently moving to a new computer, so i could only find this example
> in vbs. But i think it should give you the necessary information to
> implement this in js. Do note how I enumerate the ScriptMaps property.
>
> Also see (I only use Extensions and ScriptProcessor, there is also Flags
> and IncludedVerbs):
> http://msdn2.microsoft.com/en-us/library/ms526052.aspx
>
>
> strComputer = "."
> Set objWMIService = GetObject _
> ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
> & strComputer & "\root\microsoftiisv2")
>
> Set colItems = objWMIService.ExecQuery _
> ("Select * from IIsWebDirectorySetting")
>
> For Each objItem in colItems
> WScript.Echo( " App: " + objItem.AppFriendlyName)
>
> For i = 0 to Ubound(objItem.ScriptMaps)
> Wscript.Echo "Extension: " & _
> objItem.ScriptMaps(i).Extensions
> Wscript.Echo "Executable: " & _
> objItem.ScriptMaps(i).ScriptProcessor
> Next
> Next
>
>
> --
> Regards,
> Kristofer Gafvert
> http://www.gafvert.info/iis/ - IIS Related Info
>
>
> spitfire wrote:
>
>>This is what I have tried:
>>
>>------------
>>
>>var query = "SELECT AppPoolId, AppFriendlyName, ScriptMaps FROM
>>IIsWebDirectorySetting";
>>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>>var sites = providerObj.ExecQuery(query);
>>var i = 0;
>>
>>if ( sites.Count != 0 )
>>{
>>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
>> var item = e.item();
>>WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID + "
>>AAA: " + item.ScriptMaps);
>>
>> //seems ScriptMaps is Empty
>> for ( ScriptMap in item.ScriptMaps ) {
>> WScript.Echo("val is: " + ScriptMap);
>> }
>>
>>}
>>}
>>else {
>>WScript.Echo("No Sites Found");
>>}
>>
>>
>>
>>"Kristofer Gafvert" wrote in message
>>news:xn0fdxfo7x8t93i01r@news.microsoft.com...
>>>Hi,
>>>
>>>AspScriptLanguage has nothing to do with ASP.NET. You need to use the
>>>ScriptMaps property to figure out the version of ASP.NET the application
>>>is using.
>>>
>>>If I understand your task correctly, this script will do exactly what you
>>>want to do:
>>>
>>>http://blog.crowe.co.nz/archive/2006/08/15/676.aspx
>>>
>>>It does however not use WMI...
>>>
>>>
>>>-- Regards,
>>>Kristofer Gafvert
>>>http://www.gafvert.info/iis/ - IIS Related Info
>>>
>>>
>>>spitfire wrote:
>>>
>>>>Hi,
>>>>
>>>>This is my first wmi script. I am trying to list all the Applications
>>>>and associated ( Application Pools & .Net Version) .
>>>>
>>>>What works and not:
>>>>I can print Application Name and AppPool but I could not figure out how
>>>>to retrive .Net version. I checked the API at
>>>>http://msdn2.microsoft.com/en-us/library/ms525430.aspx . May be it is
>>>>not as simple as I am trying.
>>>>
>>>>
>>>>Why I want this script ?:
>>>>Because there are hundreds of web applications running in my IIS server
>>>>and I think there is one or more "application pool" that has more than
>>>>1 version (v 1.7 and v 2.0 ) of .Net application associated with it. I
>>>>am not sure exactly, but somewhere I read it can be a problem if you
>>>>have more than 1 version of .Net application running in same appPool.
>>>>
>>>>-------
>>>>var query = "SELECT AppPoolId, AppFriendlyName, AspScriptLanguage FROM
>>>>IIsWebDirectorySetting";
>>>>var providerObj = GetObject("winmgmts:/root/MicrosoftIISv2");
>>>>var sites = providerObj.ExecQuery(query);
>>>>
>>>>
>>>>if ( sites.Count != 0 )
>>>>{
>>>>for(e = new Enumerator(sites); !e.atEnd(); e.moveNext()) {
>>>>var item = e.item();
>>>>//print information
>>>>WScript.Echo( " App: " + item.AppFriendlyName +"," + item.AppPoolID );
>>>>}
>>>>}
>>>>else {
>>>>WScript.Echo("No Sites Found");
>>>>}
>>>>
>>>>
>>>>----------
>>>>
>>>>thanks in advance :)