Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get IIS application info via WMI

How would I get the actual directory path of an IIS application (virtual folder) using WMI?

like image 299
ProfK Avatar asked Feb 28 '23 19:02

ProfK


2 Answers

Use Scriptomatic V2 tools to view more samples like that :

On Error Resume Next

Const wbemFlagReturnImmediately = &h10 Const wbemFlagForwardOnly = &h20

arrComputers = Array("*") For Each strComputer In arrComputers WScript.Echo WScript.Echo "==========================================" WScript.Echo "Computer: " & strComputer WScript.Echo "=========================================="

Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\MicrosoftIISv2") Set colItems = objWMIService.ExecQuery("SELECT * FROM IIsWebVirtualDir_IIsWebVirtualDir", "WQL", _ wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems WScript.Echo "GroupComponent: " & objItem.GroupComponent WScript.Echo "PartComponent: " & objItem.PartComponent WScript.Echo Next Next

like image 125
lsalamon Avatar answered Mar 06 '23 16:03

lsalamon


Sure, it's 3 years old, but it's a nice little question. If the specification the solution must use .NET includes PowerShell, then this will do the trick. Someone may want to know some day:

$server = 'ServerName'
$query = "Select Path From IIsWebVirtualDirSetting WHERE Name = 'W3SVC/1/ROOT'"
Get-WmiObject -namespace "root/microsoftiisv2" -query $query -computername $server -authentication 6

The resulting object will contain one property named, "Path".

like image 45
codepoke Avatar answered Mar 06 '23 15:03

codepoke