Created
November 29, 2016 21:56
-
-
Save davidroberts63/a82f1d46f623c7627112e5a86a96831e to your computer and use it in GitHub Desktop.
Get site bindings for all apppools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import-module webadministration | |
$ErrorActionPreference = "SilentlyContinue" | |
$bindings = Get-WebBinding | |
$bindings | Select -First 1 * | |
function GetAppPoolApps($appPool) | |
{ | |
if($appPool -like "#{*") { return } | |
$apps = Get-WebConfigurationProperty "/system.applicationHost/sites/site/application[@applicationPool='$appPool']" "machine/webroot/apphost" -name path -ErrorAction SilentlyContinue | |
if(!$apps) { return } | |
$apps = $apps.ItemXPath | |
foreach ($s in $apps) { | |
$binding = $bindings | Where { $s.Contains($_.ItemXPath) } | Select -First 1 -ExpandProperty bindingInformation | |
$name = $s -replace "\/system.applicationHost\/sites\/site\[\@name='", "" | |
$name = $name -replace "[\w-]+' and \@id='\d{1,10}'\]\/application\[\@path='", "" | |
$name = $name -replace "'\]","" | |
$out += $binding + $name + "`n" | |
} | |
return $out | |
} | |
dir iis:\apppools | Where { $_.State -eq "Started" } | %{ GetAppPoolApps($_.Name) } | Out-File "temp-bindings.txt" | |
New-OctopusArtifact "temp-bindings.txt" "$(hostname).txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment