SkyWire-PSGateway.psm1
<# .SYNOPSIS Create a new SkyWire Gateway application. .DESCRIPTION This is used to create a new SkyWire Gateway application. .PARAMETER tag The version of Gateway. .PARAMETER rootSite Specify the root IIS Site where the web applications reside (default: Default Web Site). .EXAMPLE New-SWGateway -tag POS-1337-beta .EXAMPLE New-SWGateway -tag POS-1337-beta -rootSite MyCustomSite -package C:\downloads\Gateway.zip #> function New-SWGateway { param( [Parameter(Mandatory=$true)] [string] $tag, [Parameter(Mandatory=$false)] [string] $rootSite = "Default Web Site", [Parameter(Mandatory=$false)] [string] $rootDir = "$env:PROGRAMDATA\SkyWire-PSInstaller", [Parameter(Mandatory=$false)] [string] $name = "$tag-Gateway" ) if (!$rootSite) { throw "The parameter rootSite is required." } $package = Get-SWInstallPackage -app "Gateway" -tag $tag -rootDir $rootDir $parameters = @{ "IIS Web Application Name" = "$rootSite/$($name)" } if (!(Test-Path $package)) { throw "Package does not exist." } try { Restore-WDPackage $package -Parameters $parameters } catch { Write-Error "An error occurred while installing the gateway. This can be caused by an IIS permissions or configuration problem, such as web deploy not being installed." throw $_.Exception } } <# .SYNOPSIS Remove an existing SkyWire Gateway application. .DESCRIPTION This will remove a SkyWire Gateway application in IIS. .PARAMETER tag The version of the Gateway. .PARAMETER rootSite Specify the root IIS Site where the web applications reside (default: Default Web Site). .PARAMETER name If the Gateway was deployed to a custom name, specify name (default: $tag-Gateway). .PARAMETER workingDir The directory of the Gateway application (default: C:\inetpub\wwwroot\$name). .EXAMPLE Remove-SWGateway -tag POS-1337-beta .EXAMPLE Remove-SWGateway -tag POS-1337-beta -rootSite MyCustomSite .EXAMPLE Remove-SWGateway -name MyGateway #> function Remove-SWGateway { param( [Parameter(Mandatory=$false)] [string] $tag, [Parameter(Mandatory=$false)] [string] $rootSite = "Default Web Site", [Parameter(Mandatory=$false)] [string] $name = "$tag-Gateway", [Parameter(Mandatory=$false)] [string] $workingDir = "C:\inetpub\wwwroot\$name" ) try { Remove-WebApplication -Site $rootSite -Name $name Remove-Item -Path $workingDir -Recurse -Force } catch { Write-Error "An error occurred while removing the gateway. This can be caused by an IIS permissions or configuration problem, such as web deploy not being installed, or if the gateway is currently open in a web browser." throw $_.Exception } } |