Restart-VSS.ps1 Script

  • 22 October 2020
  • 3 comments
  • 168 views

Userlevel 3
Badge

One thing I’ve found as a Veeam customer is you often have to restart the VSS services on your SQL and other VSS aware servers. Here’s a script I wrote to do just that.

#   Name:   Restart-VSS.ps1
# Description: Restarts list of services in an array on VMs with a given vSphere tag. Helpful for Veeam B&R processing
# For more info on Veeam VSS services that may cause failure see https://www.veeam.com/kb2041

Import-Module VMware.PowerCLI

$vcenter = "vcenter.domain.com"
$services = @("SQLWriter","VSS")
$tag = "myAwesomeTag"
Connect-VIServer $vcenter
$vms = Get-VM |where {$_.Tag -ne $tag}

ForEach ($vm in $vms){
ForEach ($service in $services){
If (Get-Service -ComputerName $vm -Name $service -ErrorAction SilentlyContinue) {
Write-Host $service "on computer" $vm "restarting now."
Restart-Service -InputObject $(Get-Service -Computer $vm -Name $service);
}
}
}

 


3 comments

Userlevel 1
Badge

Extremely timely post!  I will definitely share this!  Thank you!

Userlevel 7
Badge +2

Very nice script Jim, thank you for sharing. It seems this might not have been a one-off issue if you created this script, did you find the root cause of why the services need to be restarted?

Userlevel 3
Badge

Hey Ras, yes especially with Server 2016 The VSS writers are prone to hanging during long running Veeam jobs. You’ll find it the next job run when the job fails during the guest processing portion. Simply restarting the services fixes the issue.

Comment