86 lines
2.6 KiB
PowerShell
86 lines
2.6 KiB
PowerShell
function Get-ExistingWebApps {
|
|
<#
|
|
Results:
|
|
PS Microsoft.PowerShell.Core\FileSystem::\\mac\home\DevRoot\SDK\alkami.powershell.sdk> Get-ExistingWebApps -IsClient
|
|
[Get-ExistingWebApps] : Found these Web Applications ["/Isotope"]
|
|
[
|
|
{
|
|
"PhysicalPath": "C:\\ProgramData\\chocolatey\\lib\\Alkami.WebApps.Isotope\\Content\\App",
|
|
"name": "Isotope",
|
|
"applicationPool": "WebClient",
|
|
"path": "/Isotope",
|
|
"preloadEnabled": true,
|
|
"Origin": "Client"
|
|
}
|
|
]
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(ParameterSetName='IsClient',Mandatory=$true)]
|
|
[switch]$IsClient,
|
|
[Parameter(ParameterSetName='IsAdmin',Mandatory=$true)]
|
|
[switch]$IsAdmin,
|
|
[Parameter(ParameterSetName='IsLegacy',Mandatory=$true)]
|
|
[switch]$IsLegacy
|
|
)
|
|
|
|
$loglead = (Get-LogLeadName)
|
|
|
|
$webApplications = @()
|
|
$origin = "Client"
|
|
|
|
if ($IsLegacy) {
|
|
## Use of this function ensures that the Default Web Site exists
|
|
$defaultWebsite = (Get-DefaultWebsite)
|
|
if ($null -eq $defaultWebsite) {
|
|
$defaultWebsite = Invoke-CommandWithRetry -ScriptBlock { return (New-DefaultWebsite) } @icwrSplat
|
|
}
|
|
## Ensure we add this to the list of sites we are going to be installing to
|
|
$siteList += $defaultWebsite
|
|
|
|
$parentAppName = $defaultWebsite.Name
|
|
$origin = "Legacy"
|
|
} else {
|
|
## By process of elimination, if you weren't in parameter set IsAdmin or IsLegacy, you must be in IsClient.
|
|
$parentAppName = 'WebClient'
|
|
|
|
if ($IsAdmin) {
|
|
$parentAppName = 'WebClientAdmin'
|
|
$origin = "Admin"
|
|
}
|
|
|
|
$webApplications = (Get-WebApplication -Site $parentAppName)
|
|
}
|
|
|
|
if (Test-IsCollectionNullOrEmpty $webApplications) {
|
|
Write-Host "$logLead : Can't find any Web Applications bound to: [$parentAppName]"
|
|
#throw "$logLead : Can't find any Web Applications bound to: [$parentAppName]"
|
|
} else {
|
|
Write-Host "$logLead : Found these Web Applications [`"$(($webApplications.path) -join '`",`"')`"] in $($parentAppName)"
|
|
}
|
|
|
|
$webApps = @()
|
|
|
|
foreach ($webApplication in $webApplications) {
|
|
<#Gather the following information and put into an object for later consumption
|
|
"path": "/Isotope",
|
|
"applicationPool": "WebClient",
|
|
"preloadEnabled": true,
|
|
"PhysicalPath": "C:\\ProgramData\\chocolatey\\lib\\Alkami.WebApps.Isotope\\content\\App"#>
|
|
|
|
$webApp = @{
|
|
name = $webApplication.path -Replace '[/]', '' # remove leading '\'
|
|
path = $webApplication.path
|
|
applicationPool = $webApplication.applicationPool
|
|
preloadEnabled = $webApplication.preloadEnabled
|
|
PhysicalPath = $webApplication.PhysicalPath
|
|
Origin = $origin
|
|
NeedsShared = $false
|
|
}
|
|
|
|
$webApps += $webApp
|
|
}
|
|
|
|
#Write-Host (ConvertTo-Json $webApps)
|
|
return $webApps
|
|
} |