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

44 lines
1.3 KiB
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function Get-IISSiteList {
<#
.SYNOPSIS
Returns a list of all Alkami sites in IIS
.PARAMETER adminSitesOnly
[switch] Opens only Admin sites on the server. Cannot be used with the IncludeIPSTS parameter
.PARAMETER returnIPSTS
[switch] IPSTS is excluded by default, but will be returned if this parameter is set. Cannot be used
with the AdminOnly parameter
#>
[CmdletBinding(DefaultParameterSetName = 'NoParameters')]
[CmdletBinding()]
Param(
[Parameter(ParameterSetName = 'AdminOnly', Mandatory = $true)]
[Parameter(Mandatory = $false)]
[Alias("AdminOnly")]
[switch]$adminSitesOnly,
[Parameter(ParameterSetName = 'IncludeIPSTS', Mandatory = $true)]
[Parameter(Mandatory = $false)]
[Alias("IncludeIPSTS")]
[switch]$returnIPSTS
)
$mgr = New-Object Microsoft.Web.Administration.ServerManager
[Regex]$siteMatchRegex = ".*WebClient.*"
if ($adminSitesOnly.IsPresent) {
[Regex]$siteMatchRegex = ".*WebClientAdmin$"
} elseif ($returnIPSTS.IsPresent) {
[Regex]$siteMatchRegex = "(.*WebClient.*|.*IPSTS)"
}
[array]$sites = $mgr.Sites | Where-Object {$_.Applications["/"].VirtualDirectories["/"].PhysicalPath -match $siteMatchRegex}
return $sites
}