PowerShell script exchange
Post Reply
Markus.K1985
Veeam Vanguard
Posts: 103
Liked: 28 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Failed to Load Module Veeam.Backup.Powershell

Post by Markus.K1985 »

Hello,

a few users of my scripts reported issues like that:
It seems I’ve found the cause of the issue. For some reason PRTG won’t find the module when using: Import-module -name Veeam.Backup.Powershell as it claims it can’t find it.
However, if I after “-name”, specify the complete path to the Veeam.Backup.Powershell.dll, the script is successful. So the script is working fine and as intended, and the issue seems to be on our server and it’s ability to load the Module at times.
Not all have tried to import the dll, but all have the situation where the module does not seem to be available to all users.

Has anyone seen something similar?

Best Wishes
Markus
johan.h
Veeam Software
Posts: 712
Liked: 182 times
Joined: Jun 05, 2013 9:45 am
Full Name: Johan Huttenga
Contact:

Re: Failed to Load Module Veeam.Backup.Powershell

Post by johan.h » 1 person likes this post

I've seen this with other modules too, sometimes you'll have to specify the exact path, if it isn't available as part of the system environment variables.

https://docs.microsoft.com/en-us/powers ... rshell-7.1
MichaelCade
Veeam Software
Posts: 314
Liked: 74 times
Joined: Mar 23, 2015 11:55 am
Full Name: Michael Cade
Location: Cambridge, United Kingdom
Contact:

Re: Failed to Load Module Veeam.Backup.Powershell

Post by MichaelCade » 1 person likes this post

Yes in my automation scripts I used

Import-module -name "C:\Program Files\Veeam\Backup and Replication\Console\Veeam.Backup.PowerShell\Veeam.Backup.PowerShell.psd1"

this is ran in the same shell when the unattended installation has completed. Then a new PowerShell window is open to run the Veeam configuration script
Regards,

Michael Cade
Global Technologist
Veeam Software
Email: Michael.Cade@Veeam.com
Twitter: @MichaelCade1
Markus.K1985
Veeam Vanguard
Posts: 103
Liked: 28 times
Joined: Dec 08, 2014 2:30 pm
Full Name: Markus Kraus
Contact:

Re: Failed to Load Module Veeam.Backup.Powershell

Post by Markus.K1985 » 1 person likes this post

Thanks for the hint and the feedback.

I will see if this hack makes it a bit more robust:

Code: Select all

    # Make sure PSModulePath includes Veeam Console
    $MyModulePath = "C:\Program Files\Veeam\Backup and Replication\Console\"
    $env:PSModulePath = $env:PSModulePath + "$([System.IO.Path]::PathSeparator)$MyModulePath"
    if ($Modules = Get-Module -ListAvailable -Name Veeam.Backup.PowerShell) {
        try {
            $Modules | Import-Module -WarningAction SilentlyContinue
            }
            catch {
                throw "Failed to load Veeam Modules"
                }
        }
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests