Retrieving home directory, redirect URL for IIS sites?


i'm working on script collect basic information sites running on iis 6.0 box , save comma-delimited text file. i've been able want except grabbing home directory and/or redirect url sites.

here's have far:

$objsites = [adsi]"iis://servername/w3svc"  $sitesarray = @()    # add initial item array, become column headers ...  $sitesarray += "site id,site name,host headers,secure headers, site status"    foreach ($objchild in $objsites.psbase.children)  {    if ($objchild.class -like "iiswebserver")    {      $siteinfo = $objchild.name + "," + $objchild.servercomment + "," + $objchild.serverbindings + "," + $objchild.securebindings + "," + $objchild.serverstate;      $sitesarray += $siteinfo;    }  }  $sitesarray | out-file c:\scripts\outputs\myfile.txt

any suggestions on how can these last 2 pieces of info nailed down? first script, if have suggestions improvements, i'd appreciate them much.

thanks,

josh

warning: long one-liner(s) :)

 

#v 1.0

$objsites.psbase.children | {$_.keytype -eq 'iiswebserver'} | select @{n='name';e={$_.psbase.name}},servercomment,serverbindings,securebindings,serverstate,@{n='homedirectory';e={($_.psbase.children | {$_.keytype -eq 'iiswebvirtualdir'}).path}},@{n='redirecturl';e={($_.psbase.children | {$_.keytype -eq 'iiswebvirtualdir'}).httpredirect}}

 

# v2.0

$objsites.children | {$_.schemaclassname -eq 'iiswebserver'} | select name,servercomment,serverbindings,securebindings ,serverstate,@{n='homedirectory';e={($_.children | {$_.schemaclassname -eq 'iiswebvirtualdir'}).path}},@{n='redirecturl ';e={($_.children | {$_.schemaclassname -eq 'iiswebvirtualdir'}).httpredirect}}

 


shay levy [mvp]
http://blogs.microsoft.co.il/blogs/scriptfanatic
powershell toolbar


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...