Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

PowerShellGet in non-interactive mode. Importing the module fails. Using it fails. #199

@larssb

Description

@larssb

I'm trying to use PowerShellGet in a script running through a PowerShell Scheduled Job. This gives me several issues.

  • Having PowerShellGet as part of the requiredmodules section in my modules manifest file makes my module fail to load.
  • Trying to do import-module inside the main script of my module throws this error
    .....Cannot bind argument to parameter 'Path' because it is null.
  • In turn, of course, makes Register-PSRepository not available. Even though it is my impression that PowerShell tries to load it, the error when Register-PSRepository tries to load is:
    The property 'Values' cannot be found on this object. Verify that the property exists.

Expected Behavior

If this is a bug or not, depends on the intention of PowerShellGet and the scenarios it is thought to support. However, I would like to know if the described scenario is supported. And if it should be how I can make it work.

Current Behavior

PowerShellGet does not seem to work in a non-interactive scenario. I have searched through the issues in this repo and found a couple of other described issues where the suggestion is to use the install-packageprovider ....but why should that help?

Possible Solution

To know if and then how PowerShellGet supports non-interactive (Scheduled Task or PowerShell Scheduled Job) scenarios.

Steps to Reproduce (for bugs)

  1. Program a simple script that uses PowerShellGet that does e.g. --> install-module -name "SomeModule"
  2. Create a PowerShell Scheduled Job that calls this script
  3. Make sure to log potential errors and so forth
  4. Control if "SomeModule" was installed and control your error log.
  • Alternatively doing import-module -name PowerShellGet -ErrorAction Stop and log that should also give you an idea.

Context

I'm trying to use PowerShellGet as part of a self-updating feature in my module. Using Update-module and so forth to fetch updates from our central package management repository. So it is pretty important for me to know if this can work or not.
And the script runs unattended and non-interactively on nodes throughout our IT environment. That is why I want the self-update in the first place. In order to avoid manually updating on node x,y,z.....

Your Environment

OS
Windows 2012R2 x64

PowerShellGet ver.
v1.5.0.0

Packagemanagement ver.
v1.0.0.1

PSVersionTable
PS C:> $PSVersionTable

Name Value


PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

> Get-PackageProvider
PS C:\> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

> Get-PackageProvider -ListAvailable
PS C:\> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.5.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
PowerShellGet            1.0.0.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Looking forward to hear from you

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions