locked
How to automate screen prompt questions for Install-Module RRS feed

  • Question

  • Hi All,

    I'm pushing MS Management Framework 5.1 to all my remaining Windows 7 and 8.1 PCs so I can use the PSwindowsUpdate module and cmdlets to enforce updates.

    However, installing the PSWindowsUpdate module requires user input...

    NuGet provider is required to continue...

    Do you want PowerShell to install and import the NuGet provider now?

    [Y] Yes   [N] No   [S] Suspend 

    How can I "pass" the 'Y' option back into PowerShell so I can script and automatically deploy the PSWindowsUpdate module install accordingly?

    As always, thanks in advance...

    durrie

    Wednesday, May 29, 2019 8:25 AM

Answers

  • You have your repository set wrong.  You need to set the repository to PSGallery. 

    PS C:\WINDOWS\system32> Get-PSRepository
    
    Name                      InstallationPolicy   SourceLocation
    ----                      ------------------   --------------
    PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
    
    
    PS C:\WINDOWS\system32>


    \_(ツ)_/

    • Marked as answer by durrie Tuesday, June 4, 2019 11:20 AM
    Wednesday, May 29, 2019 12:02 PM

All replies

  • Try using the -force 

    Install-Module -Name PSWindowsUpdate -RequiredVersion 2.0.0.4 -force

    No prompts asked


    Please remember to mark the replies as answers if they help

    Wednesday, May 29, 2019 8:50 AM
  • You must first install WMF 5.1 including all prerequisites.  Once this is installed set PowerShell to "RemoteSigned" from an elevated prompt.

    Once this is done you can use "Install-Module" to download and install PsWindowsUpdate.

    Without upgrading to 5.1 you can install the module directly from here: https://gallery.technet.microsoft.com/2d191bcd-3308-4edd-9de2-88dff796b0bc


    \_(ツ)_/

    Wednesday, May 29, 2019 9:07 AM
  • Already tried that but it just passed through and waits at the prompts...
    Wednesday, May 29, 2019 9:20 AM
  • Already tried that but it just passed through and waits at the prompts...

    What did you try?  You have to post clear information.

    Read this to learn how to post in a technical forum:

    How to ask   questions in a technical forum


    \_(ツ)_/

    Wednesday, May 29, 2019 9:22 AM
  • Hi JRV,

    Apologies my last response was directed at Hari VS_Kid not yourself, I should have said as much...i.e. the -Force switch does nothing when used in conjunction with Install-Module PSWindowsUpdate

    The module install process proceeds as normal and requests my user input regarding the NuGet Provider install options - Y, N or S

    Regarding your suggestions...

    I am installing WMF 5.1 completely with a system reboot before trying to execute Install-Module PSWindowsUpdate.

    Even then and with the ExecutionPolicy set to RemoteSigned the Install-Module PSWindowsUpdate still needs me to answer the NuGet Provider install options.

    So...

    My question is whether I can get the Install-Module PSWindowsUpdate command to automatically assume any of the resulting options of Y, N or S via any kind of syntax / variable / scripting command?

    Wednesday, May 29, 2019 11:57 AM
  • You have your repository set wrong.  You need to set the repository to PSGallery. 

    PS C:\WINDOWS\system32> Get-PSRepository
    
    Name                      InstallationPolicy   SourceLocation
    ----                      ------------------   --------------
    PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
    
    
    PS C:\WINDOWS\system32>


    \_(ツ)_/

    • Marked as answer by durrie Tuesday, June 4, 2019 11:20 AM
    Wednesday, May 29, 2019 12:02 PM
  • Thanks JRV,

    I can confirm that once I trust the PSGallery repository the Install-Module command automatically completed...however...

    I now have a "chicken & egg" situation...

    Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

    Also requires user input?

    I'm trying to totally automate this process into a PS1 file that I can remotely and silently execute?

    Wednesday, May 29, 2019 1:39 PM
  • You only have to set that once.  It is a permanent setting.

    That line does not cause a prompt.


    \_(ツ)_/

    Wednesday, May 29, 2019 1:50 PM
  • Thanks for this Hari VS_Kid,

    I used this suggestion with some success but want the latest version to always be used...the following was my resultant working code.

    Install-PackageProvider -Name NuGet -Force
    Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
    Install-Module PSWindowsUpdate
    Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false

    My actual problem was I was not reading the screen and installing the NuGet Package provider first up as per the above working code.

    Tuesday, June 4, 2019 11:14 AM
  • Thank you JRV,

    As mentioned above my actual problem was my own ridiculous inability to read the original worming prompt and address the NuGet Package Provider first!

    Following is resultant working code for remote silent execution..

    Install-PackageProvider -Name NuGet -Force
    Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
    Install-Module PSWindowsUpdate
    Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false

    Tuesday, June 4, 2019 11:20 AM
  • There is no need to install NuGet.  PowerShell come with "PowerShellGet".  That is the provider that PS uses.  It does not use NuGet.


    \_(ツ)_/

    Tuesday, June 4, 2019 11:55 AM