54 lines
2.0 KiB
PowerShell
54 lines
2.0 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Stops all Veeam Backup & Replication related services on the local machine.
|
|
.DESCRIPTION
|
|
This script identifies and stops all Windows services related to Veeam Backup & Replication.
|
|
It requires administrative privileges to run.
|
|
.NOTES
|
|
File Name : Stop-VeeamServices.ps1
|
|
Prerequisite : PowerShell 5.1 or later, Run as Administrator
|
|
Copyright : © 2023
|
|
#>
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
Write-Host "Stopping Veeam-related services..." -ForegroundColor Cyan
|
|
|
|
# Get all services with "Veeam" in their display name
|
|
$veeamServices = Get-Service | Where-Object { $_.DisplayName -like "*Veeam*" -or $_.Name -like "Veeam*" }
|
|
|
|
if (-not $veeamServices) {
|
|
Write-Host "No Veeam services found." -ForegroundColor Yellow
|
|
exit
|
|
}
|
|
|
|
Write-Host "Found the following Veeam services:" -ForegroundColor Green
|
|
$veeamServices | Format-Table -AutoSize -Property DisplayName, Status
|
|
|
|
# Stop each Veeam service
|
|
foreach ($service in $veeamServices) {
|
|
try {
|
|
if ($service.Status -eq 'Running') {
|
|
Write-Host "Stopping service: $($service.DisplayName)..." -NoNewline
|
|
Stop-Service -Name $service.Name -Force -ErrorAction Stop
|
|
Write-Host " [Stopped]" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Service $($service.DisplayName) is already stopped." -ForegroundColor Gray
|
|
}
|
|
}
|
|
catch {
|
|
Write-Host " [Failed to stop]" -ForegroundColor Red
|
|
Write-Host "Error: $_" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host "`nAll Veeam services have been processed." -ForegroundColor Cyan
|
|
|
|
# Verify all services are stopped
|
|
$runningServices = $veeamServices | Where-Object { $_.Status -eq 'Running' }
|
|
if ($runningServices) {
|
|
Write-Host "Warning: The following Veeam services are still running:" -ForegroundColor Yellow
|
|
$runningServices | Format-Table -AutoSize -Property DisplayName, Status
|
|
} else {
|
|
Write-Host "All Veeam services have been successfully stopped." -ForegroundColor Green
|
|
} |