Can't run remote Windows Server backup using Powershell 7 thru SSH
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
- 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