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 %s = human-readable time difference 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

Upgrade Azure Active Directory Connect fails with unexpected error

Today, I made the decision to upgrade my test environment and update the version of…

1 month ago

Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster

Have you ever looked at your Active Directory and wondered, "Why do I still have…

2 months ago

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…

7 months 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…

11 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…

1 year 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…

1 year ago