powershellsalt-projectwindows-server

Salt - Unable to install Powershell modules remotely


Why am I getting this error when trying to install PSWindowsUpdate? I'm getting this error on all new servers.

[root@salt ~]# salt 'Windows001' psget.install PSWindowsUpdate
Windows001:
    ERROR: Issue executing powershell Install-Module -Name PSWindowsUpdate  -Force | ConvertTo-Xml -Depth 2 -As "stream". Additional info follows:

    retcode:
        1
    stderr:
        Exception calling "ShouldContinue" with "2" argument(s): "Windows PowerShell is in NonInteractive mode. Read and
        Prompt functionality is not available."
        At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7455 char:8
        +     if($Force -or $psCmdlet.ShouldContinue($shouldContinueQueryMessag ...
        +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
            + FullyQualifiedErrorId : PSInvalidOperationException

        Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201'
        or newer version of NuGet provider is installed.
        At line:1 char:1
        + Install-Module -Name PSWindowsUpdate  -Force | ConvertTo-Xml -Depth 2 ...
        + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo          : InvalidOperation: (:) [Install-Module], InvalidOperationException
            + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
    stdout:
ERROR: Minions returned with non-zero exit code


Solution

  • Figured it out. I had to run psget.bootstrap as per documentation. This will ensure that latest version of NuGet is installed remotely.

    [root@salt ~]# salt 'Windows001' psget.bootstrap
    Windows001:
        ----------
        NuGet:
            ----------
            Name:
                NuGet
            ProviderPath:
                C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll
            Version:
                2.8.5.208
    
    
    [root@salt ~]# salt 'Windows001' psget.install PowerPlan
    Windows001:
        True