32 lines
773 B
PowerShell
32 lines
773 B
PowerShell
Function Get-IISSitesByPath {
|
|
<#
|
|
.SYNOPSIS
|
|
Returns a list (array) of all site-objects from Get-IISSite where the PhysicalPath matches the string passed in
|
|
|
|
.EXAMPLE
|
|
Get-IISSitesByPath -Path C:\Orb\WebClient\
|
|
|
|
.PARAMETER Path
|
|
the path to find sites that match
|
|
#>
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory = $true, Position = 0)]
|
|
[string]$Path
|
|
)
|
|
process {
|
|
## Oneliner: ((Get-ChildItem IIS:\Sites) | Where-Object { $_.PhysicalPath -eq 'c:\orb\WebClient' })
|
|
|
|
$siteList = @()
|
|
$allSites = @(Get-ChildItem IIS:\Sites)
|
|
|
|
foreach ($oneSite in $allSites) {
|
|
|
|
if ($oneSite.PhysicalPath -eq $Path) {
|
|
$siteList += $oneSite
|
|
}
|
|
}
|
|
|
|
return $siteList
|
|
}
|
|
} |