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.

33 lines
1.1 KiB

  1. param (
  2. [Parameter(Mandatory=$true)][string]$Runner = $(
  3. Read-Host "Runner name (e.g. pEpSecRunner)" )
  4. )
  5. if ( -not $Runner.endswith("Runner") ) { $Runner = $Runner + "Runner" }
  6. $ServSuffixCount = 1
  7. $ServSuffix = ""
  8. do {
  9. $s = Get-Service "GitLab$Runner$ServSuffix" -ea 0
  10. if ($s -ne $Null) {
  11. Stop-Service "GitLab$Runner$ServSuffix" -ea 0
  12. & "$Env:ProgramFiles\GitLabCI\gitlab-runner.exe" $GitLabRunnerCmd uninstall --service "GitLab$Runner$ServSuffix"
  13. $wmi_s = Get-WmiObject -Class Win32_Service -Filter "Name='GitLab$Runner$ServSuffix'" -ea 0
  14. if ($wmi_s -ne $Null) { $wmi_s.delete() }
  15. $ServSuffixCount += 1
  16. $ServSuffix = "$ServSuffixCount"
  17. }
  18. } while ($s -ne $Null)
  19. $UserCount = 1
  20. $UserSuffix = ""
  21. do {
  22. $User = Get-LocalUser "GitLab$Runner$UserSuffix" -ea 0
  23. Remove-Item -LiteralPath "$Env:SystemDrive\Build\GitLab$Runner$UserSuffix" -Recurse -Force -ea 0
  24. if ($User -ne $Null) {
  25. Remove-LocalUser $User
  26. }
  27. $UserCount += 1
  28. $UserSuffix = "$UserCount"
  29. } while ($User -ne $Null)