The PowerShell command to get a list of package sources that are registered with the PackageManagement module is `Get-PackageSource
`. This command gets all the package sources on the local computer.
Here is the PowerShell command to get a list of package sources that are registered for a package provider.
Get-PackageSource
The Get-PackageSource
command gets only those sources that are associated with the specified provider if you provide the package provider name. By default, it returns all package sources that are registered with the PackageManagement module.
In this article, we will discuss how to list all package sources, get all package sources for the specific provider, and get sources from a package provider using the PowerShell command.
How to List All Package Sources in PowerShell
To list all package sources that are registered with PackageManagement on the local computer, use the Get-PackageSource command.
Get-PackageSource
The output of the above PowerShell script gets all the package sources on the local computer.
How to Get All Package Sources for a Specific Provider
Use the Get-PackageSource
command in PowerShell to get all package sources for a specific provider. This command uses the ProviderName
parameter.
Get-PackageSource -ProviderName NuGet
The output of the above PowerShell script gets package sources that are registered for a specific provider NuGet.
PS C:\> Get-PackageSource -ProviderName NuGet
Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://api.nuget.org/v3/index.json
How to Get Sources from a Specific Provider
To get sources from a specific provider, you can use the Get-PackageProvider
command to get the package provider and pipe into Get-PackageSource
to get all the available sources for a specific provider.
Get-PackageProvider -Name NuGet | Get-PackageSource
In the above PowerShell script, the Get-PackageProvider command uses the Name parameter to specify the provider name, NuGet. It then pipes output to the Get-PackageSource to list of all available sources for a specific provider.
The output of the above PowerShell script is:
PS C:\> Get-PackageProvider -Name NuGet | Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
nuget.org NuGet False https://api.nuget.org/v3/index.json
Conclusion
I hope the above article on how to get all package sources on the local computer using the PowerShell command Get-PackageSource
is useful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.