Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Remove NuGet Package Provider Using PowerShell

September 20, 2023
in Blog, Powershell
0
ADVERTISEMENT

Table of Contents

Remove NuGet Package Provider

Note Note: Note: To be able to undo this change later, make a note of the path reported by (Get-PackageProvider NuGet).ProviderPath and make a backup copy of that file.

In some cases, you want to remove the NuGet Provider for PowerShell. This package provider is being installed automatically then you install some modules to connect to Microsoft 365.

You can get the list of all installed package provider on your system with Get-PackageProvider cmdlet.

PS C:\> Get-PackageProvider | select Name, Version

Name          Version
----          -------
msi           3.0.0.0
msu           3.0.0.0
NuGet         2.8.5.208
PowerShellGet 1.0.0.1
Programs      3.0.0.0

We do a check the PackageManagement module and still has no Uninstall-PackageProvider command. But we found a cmdlet Uninstall-Package then we give it a try.

PS C:\> Get-Command -Module PackageManagement

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Find-Package                                       1.4.7      PackageManagement
Cmdlet          Find-PackageProvider                               1.4.7      PackageManagement
Cmdlet          Get-Package                                        1.4.7      PackageManagement
Cmdlet          Get-PackageProvider                                1.4.7      PackageManagement
Cmdlet          Get-PackageSource                                  1.4.7      PackageManagement
Cmdlet          Import-PackageProvider                             1.4.7      PackageManagement
Cmdlet          Install-Package                                    1.4.7      PackageManagement
Cmdlet          Install-PackageProvider                            1.4.7      PackageManagement
Cmdlet          Register-PackageSource                             1.4.7      PackageManagement
Cmdlet          Save-Package                                       1.4.7      PackageManagement
Cmdlet          Set-PackageSource                                  1.4.7      PackageManagement
Cmdlet          Uninstall-Package                                  1.4.7      PackageManagement
Cmdlet          Unregister-PackageSource                           1.4.7      PackageManagement

As you can see in the below out, it’s not the cmdlet to remove a package provider.

PS C:\> Uninstall-Package -Name NuGet
Uninstall-Package : No package found for 'NuGet'.

On Windows systems

Step-by-step instructions for removing the NuGet package provider:

1️⃣ Copy the path of the NuGet package-provider assembly (DLL) to the clipboard.

(Get-PackageProvider NuGet).ProviderPath | Set-Clipboard

Below are three locations that the NuGet provider can be installed in. In your machine, it could be difference, but you don’t need to care about it because it’s stored in the clipboard.

C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll
C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
C:\Users\admin\Documents\WindowsPowerShell\Modules\PackageManagement\1.4.7\fullclr\Microsoft.PackageManagement.NuGetProvider.dll

2️⃣ Before continuing, close all opening PowerShell sessions, which may include needing to exit Visual Studio Code. Deleting the DLL will only succeed if no session has it currently loaded. If that isn’t ensured, you’ll get an Access denied error, even with elevation.

PS C:\> (Get-PackageProvider NuGet).ProviderPath | Set-Clipboard
PS C:\> Remove-Item -Path $(Get-Clipboard)
Remove-Item : Cannot remove item C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll: Access to the path 'C:\Program
Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll' is denied.
At line:1 char:1
+ Remove-Item -Path $(Get-Clipboard)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Program File...GetProvider.dll:FileInfo) [Remove-Item], Unauthoriz
   edAccessException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

3️⃣ Open a new elevated PowerShell console, in which you must not have submitted any PackageManagement commands. Then submit the following command to delete the NuGet package-provider assembly (DLL):

Remove-Item -Path $(Get-Clipboard)

The NuGet package provider should be removed without any issue. You can check it got removed with Get-PackageProvider cmdlet as below:

PS C:\Users\bonben> Get-PackageProvider | select Name, Version

Name          Version
----          -------
msi           3.0.0.0
msu           3.0.0.0
PowerShellGet 1.0.0.1
Programs      3.0.0.0

On macOS and Linux:

1️⃣ Start a PowerShell session with sudo.

2️⃣ Submit the following command to delete the NuGet package-provider assembly (DLL):

(Get-PackageProvider NuGet).ProviderPath | Remove-Item -Force

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

Automatically Installs Microsoft Graph PowerShell Module if not Installed Already When Run a Script

Next Post

How to Fix Get-MgUser One or More Errors Occurred

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory