You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
param (
|
|
[Parameter(Mandatory=$true)][string]$Runner = $(
|
|
Read-Host "Runner name (e.g. pEpSecRunner)" )
|
|
)
|
|
|
|
if ( -not $Runner.endswith("Runner") ) { $Runner = $Runner + "Runner" }
|
|
$ServSuffixCount = 1
|
|
$ServSuffix = ""
|
|
|
|
do {
|
|
$s = Get-Service "GitLab$Runner$ServSuffix" -ea 0
|
|
if ($s -ne $Null) {
|
|
Stop-Service "GitLab$Runner$ServSuffix" -ea 0
|
|
& "$Env:ProgramFiles\GitLabCI\gitlab-runner.exe" $GitLabRunnerCmd uninstall --service "GitLab$Runner$ServSuffix"
|
|
$wmi_s = Get-WmiObject -Class Win32_Service -Filter "Name='GitLab$Runner$ServSuffix'" -ea 0
|
|
if ($wmi_s -ne $Null) { $wmi_s.delete() }
|
|
$ServSuffixCount += 1
|
|
$ServSuffix = "$ServSuffixCount"
|
|
}
|
|
} while ($s -ne $Null)
|
|
|
|
$UserCount = 1
|
|
$UserSuffix = ""
|
|
do {
|
|
$User = Get-LocalUser "GitLab$Runner$UserSuffix" -ea 0
|
|
Remove-Item -LiteralPath "$Env:SystemDrive\Build\GitLab$Runner$UserSuffix" -Recurse -Force -ea 0
|
|
if ($User -ne $Null) {
|
|
Remove-LocalUser $User
|
|
}
|
|
$UserCount += 1
|
|
$UserSuffix = "$UserCount"
|
|
} while ($User -ne $Null)
|
|
|