I have hit a complete roadblock and cannot figure out how to print out the virtual directories for each website in IIS 8
. I keep retrieving Applications and empty null argument errors and just can't find a way around to get the virtual directories to list out.
I need the following data to list out about the Virtual Directories:
- Physical Path
- App Pool Association
- Site Name
- Credentials
Below is the code I have been using and messing around with:
*See revised code below*
I have also used the Appcmd.exe
command to try and to list out the Virtual Directories:
C:\Windows\System32\inetsrv\appcmd.exe LIST VDIRS
But I am still not getting the output I need. Anything or any help would be highly appreciated! Thanks!
EDIT#----------------------------------------------------------------------
Got my virtual directories to list out by commenting out a couple lines but it only prints out the name and the:
- Physical Path
- App Pool Association
- Site Name
- Credentials
are still unknown to me, below is the revised code:
Import-Module WebAdministration
$Websites = Get-ChildItem IIS:\Sites
foreach($Site in $Websites)
{
$webapps = Get-WebApplication -Site $Site.name
$VDir = Get-WebVirtualDirectory -Site $Site.name #-Application $webapps.name
foreach($webvdirectory in $VDir)
{
$webvdirectory2 = $webvdirectory.path
Write-Host $webvdirectory2.split("/")[-1]
#Write-Host $webvdirectory
#Write-Host $webvdirectory.name
}
#Write-Host $VDir
}