Cannot use PowerShellGet from PowerShell Script

Ben Guenter's Avatar

Ben Guenter

14 Nov, 2017 05:17 PM

Hi there,
I cannot use PowerShellGet on my server, whenever I try I get an error akin to this:
"PackageManagement\Save-Package : Unable to find module providers (PowerShellGet)."

It's the same on Install-Package.
I'm using Windows Server 2012 with WMF 3.
I installed the MSI for PowerShellGet as indicated by this page https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module
That gave me the same error, then I tried grabbing the latest 'PackageManagement' and 'PowerShellGet' modules locally and importing them into a powershell session on the target machine.
Resulting in the same error.

Can you help me out with this? It would be really nice to be able to install package dependencies on deployment.

  1. Support Staff 1 Posted by Alex Rolley on 16 Nov, 2017 05:38 AM

    Alex Rolley's Avatar

    Hi Ben,

    I may have missed the issue here, so if I have I do apologise.

    I've succesfully been able to install PowerShellGet on my Server 2012 test VM by following the instructions on the page that you linked to, specifically the section labeled For systems running PowerShell 3 or PowerShell 4. There is a pre-requisite in that you must have the package management MSI installed: https://www.microsoft.com/en-us/download/confirmation.aspx?id=51451

    If you are having issues installing these modules I can attempt to assist, however I will need screenshots of the errors or (if you have them) anything that has been reported in your Windows error logs.

    I look forward to hearing from you shortly,

    Regards,
    Alex

  2. 2 Posted by Ben Guenter on 16 Nov, 2017 03:55 PM

    Ben Guenter's Avatar

    Ah, sorry about that Alex, I should have been more clear. The installation of the package management msi goes fine, however, I receive the error whenever I run the 'Install-Package' or 'Save-Package' cmdlets but only when using the 'Run a Script' step from Octopus on the Server running PS3. When I remote into the machine and use a PowerShell prompt or use PowerShell remoting, I'm able to run the commands without an error. Does that make sense?

    To be specific, I'm trying to install the Azure AD cmdlets for use during the application runtime so I can't use the 'Run an Azure PowerShell Script' step.

    Attached is an example of the error I get.

  3. Support Staff 3 Posted by Alex Rolley on 24 Nov, 2017 01:47 AM

    Alex Rolley's Avatar

    Hi Ben,

    I have to apologise for the lengthy delay in this reply, I let this slip through the cracks :(

    Unfortunately I also been unable to replicate the issue that you are seeing. For my testing I installed PowerShellGet on a Server 2012R2 x64 box as per the standard instructions, the ran the following script via a Script Step in Octopus

    install-package AzureAD -force
    

    This then completed succesfully, and when I checked the installed packages on the machine itself this was the output

    PS C:\Users\alexrolley.OCTOPUS> get-installedmodule
    
    Version    Name                                Repository           Description
    -------    ----                                ----------           -----------
    2.0.0.131  AzureAD                             PSGallery            Azure Active Directory PowerShell for Graph Gene...
    1.1.7.0    PackageManagement                   PSGallery            PackageManagement (a.k.a. OneGet) is a new way t...
    1.5.0.0    PowerShellGet                       PSGallery            PowerShell module with commands for discovering,...
    

    So at this point I'm a little stumped, however it could be an environmental issue in that perhaps your environment is more locked down than mine. What I would suggest as a next step (provided you haven't already sorted this out :)) is to change the user that the Tentacle is running as to a known good account. This is fairly straightforward, we have a docs page with the instructions you need.

    Thanks Ben, please let me know how you go and if there is anything else that you need,

    Regards,

    Alex

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac