210 lines
7.6 KiB
PowerShell
210 lines
7.6 KiB
PowerShell
function Uninstall-Provider {
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
This function is used in conjunction with Alkami.Installer.Provider to uninstall legacy providers from the appropriate locations.
|
|
|
|
.DESCRIPTION
|
|
This function is used in conjunction with Alkami.Installer.Provider to uninstall legacy providers from the appropriate locations.
|
|
This function will only attempt to remove the file that matches the provider name in the alkamimanifest.xml
|
|
It will stop the following services and restart them if they were running at the time of install:
|
|
* BankService - WCF Service
|
|
* SchedulerService - WCF Service
|
|
* CoreService - WCF Service
|
|
* SecurityManagementService - WCF Service
|
|
* NagConfigurationService - WCF Service
|
|
* Nag - Windows Service
|
|
* Radium - Windows Service
|
|
|
|
.PARAMETER ProviderAssemblyInfo
|
|
[string] The provider's configured assembly info.
|
|
|
|
.PARAMETER ProviderName
|
|
[string] The provider's configured name. This is not required, it will be used for display purposes only as of Alkami.PowerShell.IIS v3.1.1
|
|
|
|
.INPUTS
|
|
Required is the ProviderAssemblyInfo and the SourcePath.
|
|
|
|
.OUTPUTS
|
|
This function will only Write-Information
|
|
|
|
.EXAMPLE
|
|
Uninstall-Provider -ProviderAssemblyInfo Alkami.App.Providers.Core.Dynamic -SourcePath C:\ProgramData\chocolatey\lib\Alkami.App.Providers.Core.Dynamic
|
|
|
|
Uninstall-Provider output may be verbose from the underlying calls being made.
|
|
|
|
#>
|
|
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $false)]
|
|
[AllowNull()]
|
|
[string]$ProviderAssemblyInfo = $null,
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
[AllowNull()]
|
|
[string]$ProviderName = $null,
|
|
|
|
[Parameter(Mandatory = $false)]
|
|
[AllowNull()]
|
|
[string[]]$ProviderTargets = @('BankService','CoreService', 'NotificationService','SecurityManagementService','Radium','Nag','NagConfigurationService','SchedulerService')
|
|
)
|
|
process {
|
|
$loglead = (Get-LogLeadName)
|
|
|
|
if (!(Test-IsAdmin)){
|
|
throw "You are not running as administrator. Can not continue."
|
|
}
|
|
|
|
## If it's a developer machine we can install anything
|
|
## Don't install on MIC or WEB servers, only APP servers.
|
|
$isDeveloperMachine = (Test-IsDeveloperMachine)
|
|
$isAppServer = (Test-IsAppServer)
|
|
$isEitherAppOrDeveloper = $isDeveloperMachine -or $isAppServer
|
|
if (!$isEitherAppOrDeveloper) {
|
|
Write-Warning "$loglead : Can only install providers on app tier machines or developer machines"
|
|
return;
|
|
}
|
|
|
|
Write-Information "$loglead : $ProviderName being uninstalled by $($env:username) on $($env:computername) at $(Get-Date)"
|
|
|
|
## These are the folders we will be copying into.
|
|
## Folders missing from this list include Notification and NagConfiguration service which may need access to providers as well.
|
|
## As ORB is moving away from a provider-centric module approach to a microservice centric approach, this should be acceptable.
|
|
$folderTargets = @()
|
|
|
|
$orbPath = (Get-OrbPath) ## Cache the lookup
|
|
|
|
## If the following services are in any status other than Stopped, we want to stop, then restart them on a NON-PROD machine.
|
|
## Production servers are always deployed to when out-of-pool, so the services are already, in theory, stopped.
|
|
$isRadiumRunning = $false
|
|
$radiumServiceName = @(Get-ServiceNamesByFragment 'Radium')[0]
|
|
if ($ProviderTargets -contains 'Radium') {
|
|
if ($radiumServiceName -ne 'Not installed') {
|
|
$isRadiumRunning = (Get-Service -Name $radiumServiceName).Status -ne 'Stopped'
|
|
$folderTargets += (Join-Path $orbPath Radium)
|
|
}
|
|
}
|
|
|
|
$isNagRunning = $false
|
|
$nagServiceName = @(Get-ServiceNamesByFragment 'Alkami Nag')[0]
|
|
if ($ProviderTargets -contains 'Nag') {
|
|
if ($nagServiceName -ne 'Not installed') {
|
|
$isNagRunning = (Get-Service -Name $nagServiceName).Status -ne 'Stopped'
|
|
$folderTargets += (Join-Path $orbPath Nag)
|
|
}
|
|
}
|
|
|
|
$isBankRunning = $false
|
|
if ($ProviderTargets -contains 'BankService') {
|
|
$isBankRunning = Test-IISAppPoolByName BankService
|
|
$folderTargets += (Join-Path (Join-Path $orbPath BankService) bin)
|
|
}
|
|
|
|
$isSchedulerRunning = $false
|
|
if ($ProviderTargets -contains "SchedulerService") {
|
|
$isBankRunning = Test-IISAppPoolByName SchedulerService
|
|
$folderTargets += (Join-Path (Join-Path $orbPath SchedulerService) bin)
|
|
}
|
|
|
|
$isCoreRunning = $false
|
|
if ($ProviderTargets -contains 'CoreService') {
|
|
$isCoreRunning = Test-IISAppPoolByName CoreService
|
|
## CoreService is included because occasionally it may use other providers.
|
|
$folderTargets += (Join-Path (Join-Path $orbPath CoreService) bin)
|
|
}
|
|
|
|
$isNagConfigRunning = $false
|
|
if ($ProviderTargets -contains 'NagConfigurationService') {
|
|
$isNagConfigRunning = Test-IISAppPoolByName NagConfigurationService
|
|
$folderTargets += (Join-Path (Join-Path $orbPath NagConfigurationService) bin)
|
|
}
|
|
|
|
$isNotifyRunning = $false
|
|
if ($ProviderTargets -contains 'NotificationService') {
|
|
$isNotifyRunning = Test-IISAppPoolByName NotificationService
|
|
$folderTargets += (Join-Path (Join-Path $orbPath NotificationService) bin)
|
|
}
|
|
|
|
$isSecMgmtRunning = $false
|
|
if ($ProviderTargets -contains 'SecurityManagementService') {
|
|
$isSecMgmtRunning = Test-IISAppPoolByName SecurityManagementService
|
|
$folderTargets += (Join-Path (Join-Path $orbPath SecurityManagementService) bin)
|
|
}
|
|
|
|
if ($isRadiumRunning) {
|
|
Stop-AlkamiService -ServiceName $radiumServiceName
|
|
}
|
|
|
|
if ($isNagRunning) {
|
|
Stop-AlkamiService -ServiceName $nagServiceName
|
|
}
|
|
|
|
if ($isBankRunning) {
|
|
Stop-IISAppPoolByName BankService
|
|
Remove-DotNetTemporaryFiles Bank
|
|
}
|
|
|
|
if ($isSchedulerRunning) {
|
|
Stop-IISAppPoolByName -Name SchedulerService
|
|
Remove-DotNetTemporaryFiles -Name SchedulerService
|
|
}
|
|
|
|
if ($isCoreRunning) {
|
|
Stop-IISAppPoolByName CoreService
|
|
Remove-DotNetTemporaryFiles CoreService
|
|
}
|
|
|
|
if ($isNagConfigRunning) {
|
|
Stop-IISAppPoolByName NagConfigurationService
|
|
Remove-DotNetTemporaryFiles NagConfigurationService
|
|
}
|
|
|
|
if ($isNotifyRunning) {
|
|
Stop-IISAppPoolByName NotificationService
|
|
Remove-DotNetTemporaryFiles NotificationService
|
|
}
|
|
|
|
if ($isSecMgmtRunning) {
|
|
Stop-IISAppPoolByName SecurityManagementService
|
|
Remove-DotNetTemporaryFiles securityManagement
|
|
}
|
|
|
|
foreach($targetFolder in $folderTargets) {
|
|
## Only remove the package file we intended to have in ORB in the first place. Anything else will not be loaded, or may be shared with another project already.
|
|
## If we attempt to delete every file in the package, we may inadvertently break other application components from running.
|
|
$targetFile = (Join-Path $targetFolder "$ProviderAssemblyInfo.dll")
|
|
if (Test-Path $targetFile) {
|
|
Write-Verbose "$loglead : Removing $targetFile"
|
|
Write-Information '.';
|
|
Remove-FileSystemItem -Path $targetFile | Out-Null
|
|
} else {
|
|
Write-Verbose "$loglead : Did not find $targetFile to remove from $targetFolder"
|
|
}
|
|
}
|
|
|
|
if ($isBankRunning) {
|
|
Start-IISAppPoolByName BankService
|
|
}
|
|
if ($isSchedulerRunning) {
|
|
Start-IISAppPoolByName SchedulerService
|
|
}
|
|
if ($isCoreRunning) {
|
|
Start-IISAppPoolByName CoreService
|
|
}
|
|
if ($isNagConfigRunning) {
|
|
Start-IISAppPoolByName NagConfigurationService
|
|
}
|
|
if ($isNotifyRunning) {
|
|
Start-IISAppPoolByName NotificationService
|
|
}
|
|
if ($isSecMgmtRunning) {
|
|
Start-IISAppPoolByName SecurityManagementService
|
|
}
|
|
if ($isRadiumRunning) {
|
|
Start-Service -Name $radiumServiceName
|
|
}
|
|
if ($isNagRunning) {
|
|
Start-Service -Name $nagServiceName
|
|
}
|
|
}
|
|
} |