63 lines
2.4 KiB
PowerShell
63 lines
2.4 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Starts all Veeam Backup & Replication related services on the local machine.
|
|
.DESCRIPTION
|
|
This script identifies and starts all Windows services related to Veeam Backup & Replication.
|
|
It requires administrative privileges to run.
|
|
.NOTES
|
|
File Name : Start-VeeamServices.ps1
|
|
Prerequisite : PowerShell 5.1 or later, Run as Administrator
|
|
Copyright : © 2023
|
|
#>
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
Write-Host "Starting 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
|
|
|
|
# Start each Veeam service
|
|
foreach ($service in $veeamServices) {
|
|
try {
|
|
if ($service.Status -ne 'Running') {
|
|
Write-Host "Starting service: $($service.DisplayName)..." -NoNewline
|
|
Start-Service -Name $service.Name -ErrorAction Stop
|
|
Write-Host " [Started]" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Service $($service.DisplayName) is already running." -ForegroundColor Gray
|
|
}
|
|
}
|
|
catch {
|
|
Write-Host " [Failed to start]" -ForegroundColor Red
|
|
Write-Host "Error: $_" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host "`nAll Veeam services have been processed." -ForegroundColor Cyan
|
|
|
|
# Verify all services are running
|
|
$stoppedServices = $veeamServices | Where-Object { $_.Status -ne 'Running' }
|
|
if ($stoppedServices) {
|
|
Write-Host "Warning: The following Veeam services failed to start:" -ForegroundColor Yellow
|
|
$stoppedServices | Format-Table -AutoSize -Property DisplayName, Status
|
|
} else {
|
|
Write-Host "All Veeam services are now running." -ForegroundColor Green
|
|
}
|
|
|
|
# Additional check for services that might be in 'StartPending' state
|
|
Write-Host "`nChecking service status after startup attempt..." -ForegroundColor Cyan
|
|
Start-Sleep -Seconds 5
|
|
$veeamServices | ForEach-Object {
|
|
$service = $_
|
|
$refreshed = Get-Service -Name $service.Name
|
|
Write-Host "$($refreshed.DisplayName) is $($refreshed.Status)" -ForegroundColor $(if ($refreshed.Status -eq 'Running') { 'Green' } else { 'Yellow' })
|
|
} |