none
Unable to install window update using Powershell Script RRS feed

  • Question

  • Hi Support,

    I am trying to install windows remotely using power shell and getting the error message.

    Invoke-AzureRmVMRunCommand  -CommandId 'RunPowerShellScript' -ScriptPath $Inputscript -Confirm:$false -Verbose | Out-File -FilePath $OutFile

    Script:

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

    Install-Module -Name PSWindowsUpdate -Force

    Import-Module -Name PSWindowsUpdate

    Install-WindowsUpdate -KBArticleID KB890830,KB2267602 -Confirm:$false -AutoReboot

    Error Message:

    Message  : Install-PackageProvider : The term 'Install-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Packages\Plugins\Microsoft.CPlat.Core.RunCommandWindows\1.1.5\Downloads\s
    cript2.ps1:2 char:1
    + Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
    + ~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (Install-PackageProvider:String)
        [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    Saturday, June 27, 2020 1:17 PM

All replies

  • Is the "PackageManagement" module installed? Is it imported?

    If it's installed it'll show up here: get-module -ListAvailable |where name -like "*package*"

    If it's been imported, it'll show up with this: get-module | where name -like "*package*"

    To import it into your session, use Import-Module PackageManagement


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Saturday, June 27, 2020 3:02 PM
  • These commands will not work on old versions of Windows or old versions  of PowerShell.


    \_(ツ)_/

    Saturday, June 27, 2020 6:15 PM
    Moderator
  • Hi Rich,

    This package is already installed but still getting the error message.

    Monday, June 29, 2020 5:54 AM
  • Hi ,

    I am using azure vm 2012 r2 , server 2016, server 2019

    Monday, June 29, 2020 5:54 AM
  • I'm not at all familiar with Azure, but there may be other requirements (prerequisites) that need to be met before you'll be able to run that cmdlet.

    If the module's installed, and you're importing it into your session, and you still can't use the cmdlet then it may also be that there's a permission issue. I'm pleading ignorance of Azure here, but does your account need permission to run certain cmdlets?

    You might want to ask your question in a product-specific forum.


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Monday, June 29, 2020 2:58 PM
  • Your endpoint does not allow those CmdLets or the remote version of PowerShell is not Windows 10 or later. (PS 5.1).

    I am pretty sure that package management does not work with PS 6 or later OpenSource versions.

    Updates cannot be installed remotely.  Some updates can be installed using the task scheduler.


    \_(ツ)_/

    Monday, June 29, 2020 4:34 PM
    Moderator
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Yang Yang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, July 3, 2020 5:47 AM