Skip to main content

Im trying to run a powershell script to turn off/on a service on the remote computer. I run Veeam VBR as a local service instead of an AD service account. Is this why my script is failing?

Ive tried both of these and using SNMP as an example. Of course they both work interactively from the VBRserver


Get-Service -computername RemoteComputer -DisplayName "SNMP Service"| Stop-Service
invoke-command -ComputerName RemoteComputer -ScriptBlock {Get-Service -Name "SNMP"| Stop-Service}
 

 

**********************
Windows PowerShell transcript start
Start time: 20250807125230
Username: WCG\SYSTEM
RunAs User: WCG\SYSTEM
Configuration Name: 
Machine: VBRserver (Microsoft Windows NT 10.0.17763.0)
Host Application: powershell.exe -ExecutionPolicy ByPass -Command  try {& 'C:\VeeamScripts\freeze-tk.ps1'  -ErrorAction Stop } catch { exit 1 } 
Process ID: 24996
PSVersion: 5.1.17763.7553
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.7553
BuildVersion: 10.0.17763.7553
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is .\RemoteComputer.log.txt
information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (RemoteComputer:String) p], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
tRemoteComputer] Connecting to remote server RemoteComputer failed with the following error message : Access is denied. For more
information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (RemoteComputer:String) R], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken
**********************
Windows PowerShell transcript end
End time: 20250807125230
**********************
 

Hi ​@TK515 ,

do you have permission to access the remote server?

Have you tried to authenticate the session?

For example:

# Create persistent sessions$sessions = New-PSSession -ComputerName "Server1"# Stop service commandInvoke-Command -Session $sessions -ScriptBlock {    Get-Service -ComputerName "Server1" -DisplayName "SNMP Service"| Stop-Service# Close sessionsRemove-PSSession -Session $sessions

@TK515, is this a pre/post job script or a pre-freeze / post-thaw script?

Pre/Post job scripts run from the VBR server itself and will execute under the context of the Backup Service account (check services.msc, check the Veeam Backup Service)

Try using Invoke-Command with the -Credential parameter, you should be able to retrieve the admin credentials within the script that way, or you can pull the creds from some encrypted file.


Hi ​@TK515 , you are absolutely right Veeam jobs run under the local system account by default which lacks permissions for remote PowerShell execution. To resolve this, configure the Veeam Backup Service to run under a domain service account with remote access rights. Also make sure WinRM is enabled and trusted between hosts. You can test connectivity using a simple PowerShell command like.

Test-WsMan -ComputerName REMOTE-PC-NAME

 

If this fails, it's likely a WinRM or permission issue.

 

 


Hello,

Not sure to understand your use case but if you want to stop snmp service I don t think you need to use remote powershell cmdlet.

Juste use stop-service snmp and use script section not in storage tab but guest application.

https://helpcenter.veeam.com/docs/backup/vsphere/backup_job_vss_scripts_vm.html?ver=120

 

If you use the pre / post job script it will be luncher with veeam service account and it will never work for remotely powershell instead if your veeam service account is a domain accout but not recommended on a standard AD architecture. You need to have a special setup to be in best practice when you join veeam to a domain  as explained here https://bp.veeam.com/security/Design-and-implementation/Hardening/Workgroup_or_Domain.html


Comment