PowerShell

Update-Module : Module ‘PowershellGet’ was not installed by using Install-Module, so it cannot be updated.

When trying to fix PowerShellGet lack of AllowPrerelease Windows actually blocked me from updating PowerShellGet which I knew is the reason why it fails in first place.

Update-Module : Module ‘PowershellGet' was not installed by using Install-Module, so it cannot be updated.
At line:1 char:1
+ Update-Module PowershellGet
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PowershellGet:String) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : ModuleNotInstalledUsingInstallModuleCmdlet,Update-Module

How can I fix it?

This is because PowerShellGet comes builtin with Windows 2016 but it's on older version. If you want all bells and whistles you need to install newest version from PowerShellGallery.

PS C:\Windows\system32> Install-Module PowerShellGet
WARNING: Version '1.0.0.1' of module 'PowerShellGet' is already installed at 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1'. To install version '1.6.7', run Instal
l-Module and add the -Force parameter, this command will install version '1.6.7' in side-by-side with version '1.0.0.1'.

PS C:\Windows\system32> Install-Module PowerShellGet -Force

Finally just restart PowerShell session and subsequent commands will work without an issue.

This post was last modified on August 22, 2018 08:57

Przemyslaw Klys

System Architect with over 14 years of experience in the IT field. Skilled, among others, in Active Directory, Microsoft Exchange and Office 365. Profoundly interested in PowerShell. Software geek.

Share
Published by
Przemyslaw Klys

Recent Posts

Active Directory Replication Summary to your Email or Microsoft Teams

Active Directory replication is a critical process that ensures the consistent and up-to-date state of…

3 weeks ago

Syncing Global Address List (GAL) to personal contacts and between Office 365 tenants with PowerShell

Hey there! Today, I wanted to introduce you to one of the small but excellent…

5 months ago

Active Directory Health Check using Microsoft Entra Connect Health Service

Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…

7 months ago

Seamless HTML Report Creation: Harness the Power of Markdown with PSWriteHTML PowerShell Module

In today's digital age, the ability to create compelling and informative HTML reports and documents…

8 months ago

How to Efficiently Remove Comments from Your PowerShell Script

As part of my daily development, I create lots of code that I subsequently comment…

9 months ago

Unlocking PowerShell Magic: Different Approach to Creating ‘Empty’ PSCustomObjects

Today I saw an article from Christian Ritter, "PowerShell: Creating an "empty" PSCustomObject" on X…

9 months ago