Link to home
Start Free TrialLog in
Avatar of detox1978
detox1978Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Unable to install PowerShell Module

Hi All,

I'm trying to run the following PowerShell command on a Windows 2012 R2 server

Get-WUInstall -AcceptAll -AutoReboot

Open in new window


But it returns the following error message

Get-WUInstall : The term 'Get-WUInstall' 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 line:1 char:1
+ Get-WUInstall -AcceptAll -AutoReboot
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-WUInstall:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Open in new window



I did the following on other servers and it worked.  So not sure what to try next....

  1. Copied uncompressed PSWindowsUpdate folder to %WINDIR%\System32\WindowsPowerShell\v1.0\Modules
  2. Run the following commands
  3. Set-ExecutionPolicy RemoteSigned

    Open in new window

     Import-Module PSWindowsUpdate

    Open in new window



Any ideas?
Avatar of Kimputer
Kimputer

Did you put it in its own folder, or just loose file in that folder you mentioned?
Avatar of detox1978

ASKER

Yeah i copied the folder and it's content.
What happens in PS when you issue this command?

Install-Module -Name PSWindowsUpdate

Open in new window

(Say Yes to all questions)
It returns the following message

Install-Module : The term 'Install-Module' 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 line:1 char:1
+ Install-Module -Name PSWindowsUpdate
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Open in new window

Check with $PSVersionTable.PSVersion that you have 5.1 installed. Otherwise update PowerShell, see https://docs.microsoft.com/en-us/skypeforbusiness/set-up-your-computer-for-windows-powershell/download-and-install-windows-powershell-5-1
It's version 4.0.

However, three other servers are working and running version 4.0
The info I can find is contradictive. On W10, PS 5 in PS 4 mode knows about Install-Module (it does not in PS 2 mode), but my notes clearly state that the required libs are available starting with PS 5 only.

Maybe you need PowerShellGet, see https://devblogs.microsoft.com/powershell/powershellget-and-packagemanagement-in-powershell-gallery-and-github/.

In restricted mode you cannot install modules either. Check with Get-ExecutionPolicy what your current mode is.

Deletion Objection: Question active again.
ASKER CERTIFIED SOLUTION
Avatar of detox1978
detox1978
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial