title: Powershell WebAdministration Iterate through Applications / Virtual Directories for a given IIS Site
body: <p>I want to do some stuff with a Site and its Sub Applications (take them off line with app_offline.htm).</p>
  
  <p>However I cannot find a way find or iterate through the virtual directories under a given site. I'm finding the site ok with </p>
  
  <pre><code>Get-ChildItem -Path IIS:\Sites | Where {$_.Name -match $siteName}
  </code></pre>
  
  <p>However I'm not sure how to drill down into it's child apps / virtual directories.</p>
  
  <p>I was thinking something like this...</p>
  
  <pre><code>Get-ChildItem -Path IIS:\Sites | Where {$_.Name -match $siteName} | `
  ForEach{
      Write-Host $_.Name
      Get-WebVirtualDirectory -site $siteName | Foreach {
          Write-Host "Virtual Dir $_"
          #DO SOME STUFF
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>