ps/Modules/Alkami.PowerShell.SDK/Public/Remove-SDKServices.ps1
2023-05-30 22:51:22 -07:00

29 lines
920 B
PowerShell

function Remove-SDKServices {
<#
.SYNOPSIS
A quick function to remove any Windows service from the services registry where the name contains "Alkami"
.DESCRIPTION
Run this to remove the Alkami services when resetting the development environment
.EXAMPLE
Remove-SDKServices
#>
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
param(
)
$continuePrompt = "Are you sure you want to remove all Alkami Windows Services?"
$yesToAll = $false
$noToAll = $false
$shouldContinue = $PSCmdlet.ShouldContinue($continuePrompt, 'Confirm', ([ref] $yesToAll), ([ref] $noToAll))
if (!$shouldContinue) {
return
}
$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)
}
}