ps/Modules/Alkami.PowerShell.IIS/Public/Get-IISSitesByPath.ps1

32 lines
773 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
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
}
}