VeeamNotify icon indicating copy to clipboard operation
VeeamNotify copied to clipboard

[BUG] DeployVeeamConfiguration.ps1 fails on Windows PowerShell 5.1 (Veeam module requires PowerShell 7) - VBR 13

Open birolbenli opened this issue 10 months ago • 5 comments

What happened?

Summary

During installation/config deployment, DeployVeeamConfiguration.ps1 fails when importing Veeam.Backup.PowerShell because the Veeam module requires PowerShell 7+, but the installer/deployment tool is running under Windows PowerShell 5.1.

Environment

  • VeeamNotify version: v2.1.2
  • Windows PowerShell version: 5.1.17763.8146
  • PowerShell 7 installed?: [Yes/No]
    • If Yes: pwsh -v output: [paste here]
  • Veeam Backup & Replication build number: 13.0.1.1071
  • OS version: [e.g., Windows Server 2019/2022 + build] (optional)

Steps to reproduce

  1. Run the installer:
    Set-ExecutionPolicy Bypass -Scope Process -Force; `
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
    iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/tigattack/VeeamNotify/main/Installer.ps1'))
    
  2. Select:
    • Download source: Version
    • Version: v2.1.2
  3. Choose to configure now (Y)
  4. Run the configuration deployment tool (Y)
  5. Error occurs during Import-Module Veeam.Backup.PowerShell

Expected behavior

The deployment tool should either:

  • run under PowerShell 7 automatically / instruct the user to run it with pwsh, OR
  • detect the PowerShell version and show a clear message before proceeding.

Actual behavior / error

Import-Module : The version of Windows PowerShell on this computer is '5.1.17763.8146'.
The module 'C:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.PowerShell\Veeam.Backup.PowerShell.psd1'
requires a minimum Windows PowerShell version of '7.0' to run.
At C:\VeeamScripts\VeeamNotify\resources\DeployVeeamConfiguration.ps1:322 char:1
+ Import-Module Veeam.Backup.PowerShell -DisableNameChecking
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable (...) [Import-Module], InvalidOperationException
    + FullyQualifiedErrorId : Modules_InsufficientPowerShellVersion,Microsoft.PowerShell.Commands.ImportModuleCommand

Suggested fix (optional)

Add a PowerShell version check at the start of the deployment script and/or installer. If $PSVersionTable.PSVersion.Major -lt 7, print instructions to run:

pwsh -NoProfile -ExecutionPolicy Bypass -File "C:\VeeamScripts\VeeamNotify\resources\DeployVeeamConfiguration.ps1"

References (format examples)

  • File path + line number:
    • resources/DeployVeeamConfiguration.ps1 line ~322 (Import-Module Veeam.Backup.PowerShell)
  • Permalink (preferred):
    • https://github.com/tigattack/VeeamNotify/blob//resources/DeployVeeamConfiguration.ps1#L322

Steps To Reproduce

No response

VeeamNotify version

v2.1.2

PowerShell version

5.1

Veeam Backup & Replication build number

13.0.1.1071

Relevant log output


birolbenli avatar Jan 12 '26 21:01 birolbenli

I'm having the same issue. spent a few days off and on messing with it and this is what I've found.

You can install it using PS7 but it will not RUN under PS7, it attempts to use 1.0... not even 5.1 as seen below from the log file. Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\VeeamScripts\VeeamNotify\Bootstrap.ps1 and generate this error:

Get-VBRJob : The term 'Get-VBRJob' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\VeeamScripts\VeeamNotify\Bootstrap.ps1:119 char:8
+ $job = Get-VBRJob -WarningAction SilentlyContinue | Where-Object {$_. ...
+        ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-VBRJob:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Side note: In VBR13 The Get-VBRJob cmdlet is deprecated for Veeam Agent jobs and policies. Run the Get-VBRComputerBackupJob cmdlet instead. Tried that and the error was the same.

Tried adding this to the top of Bootstrap.ps1 #Requires -Version 7.0 But that seems to just alert the user that its intended for PS7

So I tried adding this: if ($PSVersionTable.PSVersion.Major -lt 7) { Write-Host "Relaunching script with PowerShell 7..." Start-Process -FilePath "pwsh.exe" -ArgumentList "-File", $MyInvocation.MyCommand.Definition exit } I will actually process and not generate a Veeam error but will still error:

2026-02-03T22:01:28.813Z [INFO] Transcript is being logged to 'C:\VeeamScripts\VeeamNotify\log\2026-02-03_17.01.28_Bootstrap.log'.
2026-02-03T22:01:28.928Z [INFO] Version: v2.1.2
2026-02-03T22:01:29.159Z [INFO] Configuration validated successfully.
2026-02-03T22:01:29.163Z [INFO] Attempting to retrieve job ID and session ID from the parent process.
InvalidOperation: C:\VeeamScripts\VeeamNotify\Bootstrap.ps1:122
Line |
 122 |      $JobId = ([regex]::Matches($parentCmd, $idRegex)).Value[0]
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
InvalidOperation: C:\VeeamScripts\VeeamNotify\Bootstrap.ps1:122
Line |
 122 |      $JobId = ([regex]::Matches($parentCmd, $idRegex)).Value[0]
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

InvalidOperation: C:\VeeamScripts\VeeamNotify\Bootstrap.ps1:123
Line |
 123 |      $SessionId = ([regex]::Matches($parentCmd, $idRegex)).Value[1]
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.
InvalidOperation: C:\VeeamScripts\VeeamNotify\Bootstrap.ps1:123
Line |
 123 |      $SessionId = ([regex]::Matches($parentCmd, $idRegex)).Value[1]
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot index into a null array.

2026-02-03T22:01:30.171Z [INFO] Getting VBR job details
2026-02-03T22:01:30.547Z [ERROR] Job with ID   not found in tape jobs. Exiting.
2026-02-03T22:01:30.563Z [INFO] Stopping transcript logging.

I think this may be due to it "relaunching" under PS7 and loosing the JobID along the way. I cannot figure out how to make it initially launch under PS7.

nathanrsi avatar Feb 06 '26 15:02 nathanrsi

I've had the similar problem upgrading from veeam 12 to 13 but VeeamNotify war already installed. Basically the problem is that Veeam modules are now only used with Powershell 7. I managed to have my TELEGRAM notifications working "migrating" scripts to use powershell 7, here are the steps:

  • In veeam job i run the script with this command: "C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -ExecutionPolicy Bypass -File C:\VeeamScripts\VeeamNotify\Bootstrap.ps1
  • In Bootstrap.ps1 I modified the line 182 to: $powershellExePath = (Get-Command -Name 'pwsh.exe' -ErrorAction Stop).Path
  • In resources/NotificationSender.psm1 i commented out line 32

powercla55 avatar Mar 11 '26 11:03 powercla55

I've had the similar problem upgrading from veeam 12 to 13 but VeeamNotify war already installed. Basically the problem is that Veeam modules are now only used with Powershell 7. I managed to have my TELEGRAM notifications working "migrating" scripts to use powershell 7, here are the steps:

* In veeam job i run the script with this command: `"C:\Program Files\PowerShell\7\pwsh.exe" -NoProfile -ExecutionPolicy Bypass -File C:\VeeamScripts\VeeamNotify\Bootstrap.ps1`

* In Bootstrap.ps1 I modified the line 182 to: `$powershellExePath = (Get-Command -Name 'pwsh.exe' -ErrorAction Stop).Path`

* In resources/NotificationSender.psm1 i commented out line 32

This method worked for me with Discord notifications as well. Thanks for sharing!

ZacharyPax avatar Mar 13 '26 14:03 ZacharyPax

Hi, I tired the above but I get error messages:

2026-03-23T11:02:42.133Z [INFO] Transcript is being logged to 'C:\VeeamScripts\VeeamNotify\log\2026-03-23_22.02.25-VWLC-VWLC2_clone1_(Incremental).log'. 2026-03-23T11:02:56.303Z [INFO] No update available. 2026-03-23T11:02:56.357Z [DEBUG] Skipping Discord notification as it is not enabled. 2026-03-23T11:02:56.362Z [DEBUG] Skipping Slack notification as it is not enabled. PS>TerminatingError(Invoke-RestMethod): "The format of value 'VeeamNotify; PowerShell/7.6' is invalid." 2026-03-23T11:02:56.576Z [ERROR] Teams notification could not be sent: StatusDescription=; StatusCode=; Message= PS>TerminatingError(Invoke-RestMethod): "The format of value 'VeeamNotify; PowerShell/7.6' is invalid." 2026-03-23T11:02:56.794Z [ERROR] Telegram notification could not be sent: StatusDescription=; StatusCode=; Message= 2026-03-23T11:02:56.803Z [DEBUG] Skipping Http notification as it is not enabled. 2026-03-23T11:02:56.820Z [DEBUG] Running log cleanup. VERBOSE: Performing the operation "Remove expired log files" on target "C:\VeeamScripts\VeeamNotify\log". 2026-03-23T11:02:56.832Z [DEBUG] Searching for log files older than 7 days. 2026-03-23T11:02:56.863Z [DEBUG] Found 0 logs files exceeding retention period. 2026-03-23T11:02:56.866Z [INFO] Stopping transcript logging.

jamesl1234 avatar Mar 23 '26 11:03 jamesl1234

Thanks for your input, everyone. I'll prepare a patch for this when I have some time. I would be grateful of a PR if anyone wishes to contribute.


You can install it using PS7 but it will not RUN under PS7, it attempts to use 1.0... not even 5.1 as seen below from the log file. Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe [...]

@nathanrsi this is simply Windows weirdness. Despite the stupid path, this is the location of PowerShell 5.1 on all modern systems, as demonstrated on a Windows Server 2022 machine:

> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "echo $PSVersionTable"

Name                           Value
----                           -----
PSVersion                      5.1.20348.4294

tigattack avatar Jun 16 '26 16:06 tigattack