0

I have a custom array

$myresults = @() 
$w3svcID = $result.ReturnValue -replace "IISWebServer=", "" 
$w3svcID = $w3svcID -replace "'", "" 
$vdirName = $w3svcID = "/ROOT"; 
$vdirs = gwmi -namespace "root\MicrosoftIISv2" -class "IISWebVirtualDirSetting" 
foreach($vdir in $vdirs) 
{ 
 $vPool = $vdir.Apppoolid 
 $vName = $vdir.Name 

 $robj = New-Object System.Object  
 $robj | Add-Member -type NoteProperty -name Path -value $vName  
 $robj | Add-Member -type NoteProperty -name Pool -value $vPool  
 $myresults += $robj 
} 
$myresults | group-object Pool

I'd like to be able to Group the data in the form of a list where the group values (Path) is under the group-by values (Pool); like so:

DefaultAppPool
   W3SVC\
   W3VSC\1\ROOT\
MyAppPool
   W3SVC\1\ROOT\MyVirtual\

1 Answer 1

1

Give this a try:

Get-WmiObject IISWebVirtualDirSetting -Namespace root\MicrosoftIISv2  |
Group-Object AppPoolId | Foreach-Object{
    $_.Name
    $_.Group | Foreach-Object { "`t$($_.Name)" }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.