195 lines
6.0 KiB
PowerShell
195 lines
6.0 KiB
PowerShell
|
function Stop-AlkamiServicesForDeletetion {
|
||
|
|
||
|
[System.Collections.ArrayList]$stopLast = "Alkami.MicroServices.Broker.Host", "Alkami.Services.Subscriptions.Host";
|
||
|
|
||
|
|
||
|
Get-Service alkami* | Where-Object { $_.Status -eq "Running" } | ForEach-Object { Set-service -Name $_.Name -StartupType "manual" }
|
||
|
#stop everyhing but broker sub service
|
||
|
(Get-Service alkami*) | ForEach-Object {
|
||
|
if ( $stopLast -contains $_.Name) {
|
||
|
#do nothing
|
||
|
}
|
||
|
else {
|
||
|
Stop-AlkamiService -ServiceName $_.Name
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#stop broker and sub service
|
||
|
(Get-Service alkami*) | ForEach-Object {
|
||
|
if ( $stopLast -contains $_.Name) {
|
||
|
Stop-AlkamiService -ServiceName $_.Name
|
||
|
}
|
||
|
else {
|
||
|
#donothing
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function Remove-AlkamiChocoPackageFolders {
|
||
|
$ChocoInstallPath = "C:\ProgramData\chocolatey\lib\";
|
||
|
# $ChocoInstallPath = "C:\test\";
|
||
|
Get-ChildItem -Path $ChocoInstallPath Alkami* | ForEach-Object {
|
||
|
$PathToRemove = $ChocoInstallPath + $_;
|
||
|
Write-Host removeing $ChocoInstallPath$_;
|
||
|
remove-item -Path $PathToRemove -Recurse -Force;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function Remove-OrbFolder {
|
||
|
Write-Host "removing orb folder"
|
||
|
$OrbFilePath = "C:\Orb";
|
||
|
remove-item -Path $OrbFilePath -Recurse -Force;
|
||
|
|
||
|
}
|
||
|
function Remove-ServicesFromRegistry {
|
||
|
$serviceNames = (Get-ServiceInfoByCIMFragment C:\programdata\chocolatey\lib\).Where({ $_.Name -match 'Alkami' -and $_.Name -ne "Alkami.Sidekick.Client" }).Name
|
||
|
foreach ($service in $serviceNames) {
|
||
|
Invoke-SCExe @('delete', $service)
|
||
|
}
|
||
|
}
|
||
|
#flags to add
|
||
|
#-sites remove IIS sites
|
||
|
#-appPools remove App pools added by alkami
|
||
|
#-devDb remove developer dynamic database
|
||
|
#-MainDb remove main database
|
||
|
|
||
|
#add other flags/methods that group the above items like
|
||
|
#-full
|
||
|
#that will remove everything
|
||
|
|
||
|
function Remove-SDK {
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
param (
|
||
|
#Removes the developer dynamic database, will not remove stage match database
|
||
|
[switch] $DevDb,
|
||
|
|
||
|
#Removes IIS dev and admin sites, does not remove the stage match site
|
||
|
[switch] $Sites,
|
||
|
|
||
|
#Removes The Webclient App pool
|
||
|
[Switch] $AppPools,
|
||
|
|
||
|
#combines the following flags into one $DevDb $Sites $AppPools
|
||
|
[Switch] $Hard
|
||
|
)
|
||
|
Remove-SDKCore;
|
||
|
|
||
|
|
||
|
if ($DevDb) {
|
||
|
#remove developerDynamic database
|
||
|
remove-DevDynamicDB;
|
||
|
Write-Host "-----------------";
|
||
|
}
|
||
|
|
||
|
if ($Sites) {
|
||
|
#remove iis sites
|
||
|
|
||
|
remove-DeveloperDevIisSites;
|
||
|
Write-Host "-----------------";
|
||
|
}
|
||
|
if ($AppPools) {
|
||
|
remove-WebCLientAppPool
|
||
|
Write-Host "-----------------";
|
||
|
#remove app pools
|
||
|
}
|
||
|
|
||
|
if ($Hard) {
|
||
|
#Hard reset
|
||
|
remove-DevDynamicDB;
|
||
|
Write-Host "-----------------";
|
||
|
remove-AlkamiMasterDB;
|
||
|
Write-Host "-----------------";
|
||
|
remove-DeveloperDevIisSites;
|
||
|
Write-Host "-----------------";
|
||
|
remove-WebCLientAppPool;
|
||
|
Write-Host "-----------------";
|
||
|
remove-ChocoSources;
|
||
|
Write-Host "-----------------";
|
||
|
remove-NugetSource;
|
||
|
Write-Host "-----------------";
|
||
|
remove-portExclusions;
|
||
|
Write-Host "-----------------";
|
||
|
}
|
||
|
Start-IISOnly;
|
||
|
|
||
|
}
|
||
|
|
||
|
function Remove-SDKCore {
|
||
|
|
||
|
Stop-AlkamiServicesForDeletetion;
|
||
|
Write-Host "-----------------";
|
||
|
Stop-IISOnly;
|
||
|
Write-Host "-----------------";
|
||
|
Remove-AlkamiChocoPackageFolders;
|
||
|
Write-Host "-----------------";
|
||
|
Remove-OrbFolder;
|
||
|
Write-Host "-----------------";
|
||
|
Remove-ServicesFromRegistry;
|
||
|
Write-Host "-----------------";
|
||
|
}
|
||
|
function remove-DevDynamicDB {
|
||
|
#alkami.machinesetup.sdk.database
|
||
|
Write-Host "removing DeveloperDynamic database";
|
||
|
invoke-sqlcmd -Query "alter database DeveloperDynamic set single_user with rollback immediate; Drop database DeveloperDynamic;"
|
||
|
}
|
||
|
function remove-AlkamiMasterDB {
|
||
|
#alkami.machinesetup.sdk.database
|
||
|
Write-Host "removing AlkamiMaster database";
|
||
|
invoke-sqlcmd -Query "alter database AlkamiMaster set single_user with rollback immediate; Drop database AlkamiMaster;"
|
||
|
Write-Host "removing Database Standup variable";
|
||
|
Remove-EnvironmentVariable -Name "Alkami_SDK_Initialization_DatabaseStandup" -StoreName "Process"
|
||
|
Remove-EnvironmentVariable -Name "Alkami_SDK_Initialization_DatabaseStandup" -StoreName "Machine"
|
||
|
}
|
||
|
function remove-DeveloperDevIisSites {
|
||
|
|
||
|
Write-Host "removing developer.dev.alkamitech.com";
|
||
|
Remove-IISSite -Name "developer.dev.alkamitech.com";
|
||
|
|
||
|
Write-Host "removing admin-developer.dev.alkamitech.com";
|
||
|
Remove-IISSite -Name "admin-developer.dev.alkamitech.com";
|
||
|
|
||
|
Write-Host -Name "legacy WebClient client"
|
||
|
Remove-IISSite -Name "WebClient";
|
||
|
|
||
|
Write-Host -Name "legacy WebClient client"
|
||
|
Remove-IISSite -Name "WebClientAdmin";
|
||
|
|
||
|
|
||
|
}
|
||
|
function remove-portExclusions {
|
||
|
Write-Host -Name "remove port exclusions"
|
||
|
netsh int ipv4 delete excludedportrange protocol=tcp startport=12345 numberofports=2
|
||
|
netsh int ipv4 delete excludedportrange protocol=tcp startport=50000 numberofports=30
|
||
|
}
|
||
|
Function remove-WebCLientAppPool {
|
||
|
Write-Host "removing App Pools";
|
||
|
Remove-WebAppPool -Name "WebClient"
|
||
|
Remove-WebAppPool -Name "Admin"
|
||
|
Remove-WebAppPool -Name "WebClientAdmin"
|
||
|
Remove-WebAppPool -Name "STSConfiguration"
|
||
|
Remove-WebAppPool -Name "SecurityManagementService"
|
||
|
Remove-WebAppPool -Name "RP-STS"
|
||
|
Remove-WebAppPool -Name "NotificationService"
|
||
|
Remove-WebAppPool -Name "NagConfigurationService"
|
||
|
Remove-WebAppPool -Name "MessageCenterService"
|
||
|
Remove-WebAppPool -Name "IPSTS"
|
||
|
Remove-WebAppPool -Name "DefaultAppPool"
|
||
|
Remove-WebAppPool -Name "CoreService"
|
||
|
Remove-WebAppPool -Name "ContentService"
|
||
|
Remove-WebAppPool -Name "AuditService"
|
||
|
Remove-WebAppPool -Name "BankService"
|
||
|
}
|
||
|
|
||
|
Function remove-ChocoSources {
|
||
|
Write-Host "removing choco sources";
|
||
|
choco source remove -n="choco.dev"
|
||
|
choco source remove -n="choco.internal"
|
||
|
choco source remove -n="AlkamiChocoDev"
|
||
|
}
|
||
|
|
||
|
Function remove-NugetSource {
|
||
|
Write-Host "removing nuget source";
|
||
|
dotnet nuget remove source "Alkami Third-Party"
|
||
|
dotnet nuget remove source "Alkami Dev"
|
||
|
}
|