Can't run remote Windows Server backup using Powershell 7 thru SSH

Eldon Li 0 Reputation points Microsoft Employee
2023-04-30T11:22:43.95+00:00

Task: Run Windows Server backup (2019) using Powershell 7 SSH remote session (Win11)

Environment:

Windows Server 2019 , install Powershell 7.3.4.0, install OpenSSH

Windows 11 , install Powershell 7.3.4.0

Step

In Window 11, run PowerShell 7

1.enter a remote session under SSH

$session = New-PSSession -HostName 2019EL1 -UserName administrator

Enter-PSSession $session

  1. Find no WindowsServerBackup module avaliable, and add a WindowsServerBackup maually

import-module -Name WindowsServerBackup -SkipEditionCheck

get-module -ListAvailable

then below item added

Script 0.0 windowsserverbackup

Script 1.0 windowsServerBackup {Add-WBBackupTarget, Add-WBBareMetalRecovery, Add…

Binary 1.0.0.0 windowsServerBackup {Add-WBBackupTarget, Add-WBBareMetalRecovery, Add…

3.run Backup script (below script can run locally or thry WinRM PS session, but not in PS7 SSH remote session

============

$Policy = New-WBPolicy

Add-WBSystemState $Policy

Add-WBBareMetalRecovery $Policy

$BackupLocation = New-WBBackupTarget -VolumePath "E:"

Add-WBBackupTarget -Policy $Policy -Target $BackupLocation

Set-WBVssBackupOptions -Policy $Policy -VssCopyBackup

Start-WBBackup -Policy $Policy

============

error

$Policy = Get-WBPolicy

Add-WBSystemState $Policy

Add-WBSystemState: Cannot validate argument on parameter 'Policy'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

Anyone has any recommendation, how to resolve this error ?

Thanks

Windows for business Windows Server Devices and deployment Set up, install, or upgrade
Windows for business Windows Server User experience PowerShell
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.