WARNING: Unable to find module repositories - powershell

I tried to install Docker on activated windows server 2016 standard.
I executed “Install-Module -Name DockerMsftProvider -Repository PSGallery -Force” but failed. It suggested that can not find PSGallery. I executed "Get-PSRepository".
The error:
WARNING: Unable to find module repositories.
I googled 3 ways to solve it but none of them worked.
I executed Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Verbose -Force successfully.
I installed chocolatey successfully.
I execute "powershell Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted" but failed. It asked me to use "Register-PSRepository -Default".
I tried "powershell Register-PSRepository -Default -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted" but still failed.
How can I solve this problem?

With the deprecation of TLS 1.0 and 1.1 for PowerShell Gallery as of April 2020, the cmdlets Update-Module and Install-Module became broken. Thus, according to this article, some commands need to be executed to bring them alive again:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck
If that still doesn't work, then run the following commands:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
TLS 1.0 and 1.1 were also recently deprecated at NuGet.org:
But that was also previously announced.

Simply running Register-PSRepository -Default (without any additional parameters) worked for me. After that, the Gallery was successfully registered:
PS C:\Windows\system32> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2/

My problem was the missing Proxy config
best solution from comments:
https://www.zerrouki.com/working-behind-a-proxy/
thanks to #Vadzim
In PowerShell open Profile
PS> notepad $PROFILE
this opens Notepad with your profile setting, will be created of not exists.
then add:
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
somehow my local proxy is set but doesn't work.
same problem later with Docker, =>
> PS> [Environment]::SetEnvironmentVariable("HTTP_PROXY", http://username:password#proxy:port/", [EnvironmentVariableTarget]::Machine)
then restart docker service

I got a similar message. I ran Register-PSRepository -default and it registered ok. Then I ran Set-PSRepository -Name PSGallery -InstallationPolicy Trusted. I didn't combine the commands, but it worked.
I spent over an hour trying to pass credentials to the proxy the same way I do for Exchange Online, but no love. I disconnected and used our guest WiFi instead.

One more thing which hasn't been mentioned.
You would indeed need to run
notepad $profile
and copy paste this bit changing your proxy details:
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials = System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
But if you have HTTPS Inspection turned on, you might want to add the Man-in-the-middle Certificate to the "Trusted Root Certification Authorities"

Related

PowerShell Install-Module Error - No Match was found for specified search criteria and module name 'PackageManagement'

I am trying to run the following command in my Windows 10 PC , and PowerShell version 7.1.2
> Install-Module PowerShellGet, PackageMAnagement -Force -WarningAction SilentlyContinue
But I am getting the below error as shown in the screenshot :
-- No match was found for the specified search criteria and module name 'PackageManagement'.
Note : I am trying to run this command on my Office laptop and it is giving me this error. The same thing if I run on my personal PC , this is working fine.
I am really stuck on this for past 4 days. Please help
Edit :
If I request modules separately , that works .
Meaning , the below works fine ..
Install-Module PowerShellGet -Force -WarningAction SilentlyContinue
Install-Module PackageManagement -Force -WarningAction SilentlyContinue
If you have an authenticating proxy you'll need to account for that - Powershell does not look at the system proxy settings by default.
Try adding this before you request the module:
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
If, as the error message suggests, you type Get-PSRepository then it should return PSGallery without error if you have a connection

How to install PowerShell module pushed to Azure Artifacts in Pipelines?

Following this article I set up Pipelines to push a PowerShell module to my Artifacts feed.
I can install the module on my local machine, but I was wondering how I can do the same in Pipelines? It seems adding the NuGet source is an interactive process, so how can Pipelines add the Artifacts feed as a source?
The issue is that I don't want to have any user interaction in a CI environment.
If you are using self-hosted agent, you need to configure the folder module permission, self-hosted agent run the cmd via service account instead of personal account.
If you are using hosted agent, add the task power shell and enter below script to install the module.
$patToken = "$(pat)" | ConvertTo-SecureString -AsPlainText -Force
$credsAzureDevopsServices = New-Object System.Management.Automation.PSCredential("xxx", $patToken)
Register-PSRepository -Name "PowershellAzureDevopsServices" -SourceLocation "https://pkgs.dev.azure.com/{Org name}/{project name}/_packaging/{feed name}/nuget/v2" -PublishLocation "https://pkgs.dev.azure.com/{Org name}/{project name}/_packaging/{feed name}/nuget/v2" -InstallationPolicy Trusted -Credential $credsAzureDevopsServices
Get-PSRepository
Find-Module -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices
Install-Module -Name Get-Hello -Repository PowershellAzureDevopsServices -Credential $credsAzureDevopsServices
Get-Module -ListAvailable Get-Hello
Result:
Update1
We need to enter the code during the registration of the power supply enclosure repository, the method is Register-PSRepository
This is a certification issue, If we change the authentication method, maybe we don’t need to enter the code.
In addition, We could also install the module via the cmd Install-Module Get-Hello -Scope CurrentUser -Force

Powershell install - No match was found for the specified search criteria and module name

I am having a difficult time installing/updating my powershell modules. I noticed this when I tried installing DBA Tools moudle. Reference links are https://dbatools.io/download/ and https://github.com/sqlcollaborative/dbatools.
It's a corporate PC. But I know that I have installed other modules before in the past. Does anyone have any idea what's going on?
PS (Admin)>
Install-Module DBATools
NOTE: The Install-Module command pauses for many minutes before the command returns a warning message.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
ERROR: "PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'".
Update-Module PowerShellGet
ERROR: "Update-Module : Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.".
Update-Module PowerShellGet -Force
ERROR: "Update-Module : Module 'PowerShellGet' was not installed by using Install-Module, so it cannot be updated.".
Find-Module dbatools
NOTE: The Find-Module command pauses for many minutes before the command returns an error message.
ERROR: "No match was found for the specified search criteria and module name 'dbatools'. Try Get-PSRepository to see all available registered module repositories."
Get-PSRepository | fl *
Name : PSGallery
SourceLocation : https://www.powershellgallery.com/api/v2
Trusted : False
Registered : True
InstallationPolicy : Untrusted
PackageManagementProvider : NuGet
PublishLocation : https://www.powershellgallery.com/api/v2/package/
ScriptSourceLocation : https://www.powershellgallery.com/api/v2/items/psscript
ScriptPublishLocation : https://www.powershellgallery.com/api/v2/package/
ProviderOptions : {}
Get-Module PackageManagement -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Get-Module -ListAvailable |
Where-Object ModuleBase -like $env:ProgramFiles\WindowsPowerShell\Modules\* |
Sort-Object -Property Name, Version -Descending |
Get-Unique -PipelineVariable Module |
ForEach-Object {
if (-not(Test-Path -Path "$($_.ModuleBase)\PSGetModuleInfo.xml")) {
Find-Module -Name $_.Name -OutVariable Repo -ErrorAction SilentlyContinue |
Compare-Object -ReferenceObject $_ -Property Name, Version |
Where-Object SideIndicator -eq '=>' |
Select-Object -Property Name,
Version,
#{label='Repository';expression={$Repo.Repository}},
#{label='InstalledVersion';expression={$Module.Version}}
}
}
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
$webclient=New-Object System.Net.WebClient
$webclient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[Net.ServicePointManager]::SecurityProtocol = "tls12"
Find-Module dbatools
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'dbatools'. Try
Get-PSRepository to see all available registered module repositories.
Invoke-WebRequest https://www.powershellgallery.com/api/v2
Invoke-WebRequest : The underlying connection was closed: The connection was closed unexpectedly.
Some references I tried
windows 10 - Powershell won't install almost any module using install-module - Stack Overflow
Powershell won't install almost any module using install-module
There's a script for that: Install-Module - unable to resolve package source 'https //www.powershellgallery.com/api/v2/'
https://vanbrenk.blogspot.com/2017/09/install-module-unable-to-resolve.html
Update Manually Installed PowerShell Modules from the PowerShell Gallery – Mike F Robbins
https://mikefrobbins.com/2016/06/09/update-manually-installed-powershell-modules-from-the-powershell-gallery/
Update-Module : Module 'PowershellGet' was not installed by using Install-Module, so it cannot be updated. - Evotec
https://evotec.xyz/update-module-module-powershellget-was-not-installed-by-using-install-module-so-it-cannot-be-updated/
I ran into the same error installing different module. My fix was specifying TLS1.2 for the .net Security protocol.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Try running Register-PSRepository -Default
Thanks to Stephen, rouxquasar it worked with below order for me Windows 2016 Datacenter, KB4598243, Execution policy was set properly so didn't have to deal with that.
Enable TLS 1.2:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Register the default PS Gallery Repo (may check Get-PSRepository | fl* just incase)
Register-PSRepository -Default
Install-Module dbatools (check Find-Module before to validate)
Use -Force switch if an older version of dbatools exists.
Re-registering PS default repository as an Administrator fixed for me:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Unregister-PSRepository -Name PSGallery
Register-PSRepository -Default
Find-Module dbatools
I have tried register-psrepository and it executed with out any error but after when I try get-psrepository its was still giving same error message "WARNING: Unable to find module repositories.", I tried different option below steps worked for me:
register ps repository with a different name and use the same psgallery api for source location.
Register-PSRepository PSGallery1 -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted
set the repository
Set-PSRepository PSGallery1
now when I check the repository it worked like charm
PSGAllery1 is the Name I have used
Enabled Group Policy to allow scripts and set execution policy to bypass. I am now able to install the module. However, I must run the install with Scope current user and am still unable to install with As Admin powershell.
Module Install
Install-Module DBATools -Scope CurrentUser
Group Policy (Fix)
#*****************
FIX ...
#*****************
## PS (As Admin)
gpedit.msc
# Navigate to: Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell. Change the “Turn on Script Execution”
# Turn on Script Execution > Enabled, Policy "Allow all scripts"
## PS (As Admin)
Set-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\PowerShell -Name ExecutionPolicy -Value ByPass
<#
#*****************
REFERENCE ...
#*****************
Windows PowerShell - the setting is overridden by a policy defined at a more specific scope
https://vladtalkstech.com/2015/03/windows-powershell-updated-execution-policy-successfully-setting-overridden-policy-defined-specific-scope.html
Change the PowerShell MachinePolicy Execution Policy in WS 2012R2
https://vladtalkstech.com/2014/03/change-powershell-machinepolicy-execution-policy-windows-server-2012r2.html
#>
#*****************
CAUSE ...
#*****************
Get-ExecutionPolicy –List
Set-ExecutionPolicy -Scope MachinePolicy Unrestricted
## However, you might have an error saying it can only be done via Group Policy.
## “Set-ExecutionPolicy : Cannot set execution policy. Execution policies at the MachinePolicy or UserPolicy scopes mustbe set through Group Policy
Try running the powerShell or the WindowsTerminal as administrator, and then re-entering your command before trying any complicated solution, helps most of the time.

Unable to find repository on Update-Module

I'm using Windows 10 and Powershell 5.1
Get-PSRepository has result :
PSGallery Untrusted https://www.powershellgallery.com/api/v2
whereas Update-Module returns error
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2/'. Use
Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\powershellget\2.0.1\PSModule.psm1:13000 char:20
+ ... $sid = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Any idea of how to fix it?
TL;DR
It looks like the URL for the PSGallery repository registered in PowerShell used to point to https://www.powershellgallery.com/api/v2/ but it was changed to https://www.powershellgallery.com/api/v2 at some point (note the missing forward slash at the end).
λ Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
Any modules installed from the old URL are now failing to update. Reinstalling them from PowerShell gallery will update the repository URL, allowing the modules to be updated normally going forward. You can use the following command to reinstall all modules pointing to the old URL:
Get-InstalledModule `
| ? { $_.Repository -eq 'https://www.powershellgallery.com/api/v2/' } `
| % { Install-Package -Name $_.Name -Source PSGallery -Force -AcceptLicense }
The full run down
I have run into this incredibly annoying issue myself. From the error message we can see a couple of things:
PackageManagement\Install-Package : Unable to find repository 'https://www.powershellgallery.com/api/v2/'
PowerShellGet\Update-Module ultimately passes the buck to
PackageManagement\Install-Package
It is looking for a repository
at 'https://www.powershellgallery.com/api/v2/'
Running Get-PSRepository on my machine yields:
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Trusted https://www.powershellgallery.com/api/v2
So it looks like the repository is there, except, maybe it isn't. Take note of the trailing forward slash. Could it be that Install-Package is looking for a repository with a SourceLocation that exactly matches that string? Let's try changing the SourceLocation for PSGallery:
Set-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -InstallationPolicy Trusted
PackageManagement\Set-PackageSource : The PSGallery repository has
pre-defined locations. The 'Location, NewLocation or SourceLocation'
parameter is not allowed, try again after removing the 'Location,
NewLocation or SourceLocation' parameter. At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:11768
char:17
+ ... $null = PackageManagement\Set-PackageSource #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https://www.pow...ery.com/api/v2/:String) [Set-PackageSource],
Exception
+ FullyQualifiedErrorId : ParameterIsNotAllowedWithPSGallery,Add-PackageSource,Microsoft.PowerShell.PackageManagement.Cmdlets.SetPackageSource
Well, that didn't work. Looks like the PSGallery repository is protected for your safety.
Let's trying adding a different repository and updating a module:
Register-PSRepository -Name PSGallery1 -SourceLocation https://www.powershellgallery.com/api/v2/ -InstallationPolicy Trusted
Update-Module -Name pester -Force
Look, no error. It works!
Here is the interesting thing, if I pull up a list of installed modules I find a mix of repositories:
Get-InstalledModule | Select Name, Repository | FT -AutoSize
Name Repository
---- ----------
7Zip4Powershell PSGallery
AWSPowerShell PSGallery
cChoco PSGallery1
dbatools PSGallery
DLMAutomation PSGallery1
InvokeBuild PSGallery1
Microsoft.PowerShell.Archive PSGallery1
PackageManagement PSGallery
Pester PSGallery1
posh-git PSGallery1
powershell-yaml PSGallery1
PowerShellGet PSGallery
PowerUpSQL PSGallery1
psake PSGallery1
PsHosts PSGallery1
psTrustedHosts PSGallery1
ReverseDSC PSGallery1
SeeShell PSGallery1
SqlServer PSGallery1
TunableSSLValidator PSGallery1
xSmbShare PSGallery1
xWebAdministration PSGallery1
Look at all those modules installed form PSGallery1 which is associated with https://www.powershellgallery.com/api/v2/! Prior to just now, there has never been a repository on my machine called PSGallery1; every module I have ever installed has been from PSGallery. My guess is that the PSGallery repository used to point to https://www.powershellgallery.com/api/v2/ and at some point, intentionally or not, it was changed to https://www.powershellgallery.com/avp/v2; breaking Update-Module for any modules installed from the previous URL. I suspect that if I reinstall the modules using Install-Package from the updated PSGallery repository everything will resolve itself and I can remove the PSGallery1 repository.
Let's update all the modules that were deployed from the old URL (PSGallery1):
Get-InstalledModule `
| ? { $_.Repository -eq 'PSGallery1' } `
| % { Install-Package -Name $_.Name -Source PSGallery -Force -AcceptLicense }
Running Get-InstalledModule again yields:
Name Repository
---- ----------
7Zip4Powershell PSGallery
AWSPowerShell PSGallery
cChoco PSGallery
dbatools PSGallery
DLMAutomation PSGallery
InvokeBuild PSGallery
Microsoft.PowerShell.Archive PSGallery
PackageManagement PSGallery
Pester PSGallery
posh-git PSGallery
powershell-yaml PSGallery
PowerShellGet PSGallery
PowerUpSQL PSGallery
psake PSGallery
PsHosts PSGallery
psTrustedHosts PSGallery
ReverseDSC PSGallery
SeeShell PSGallery
SqlServer PSGallery
TunableSSLValidator PSGallery
xSmbShare PSGallery
xWebAdministration PSGallery
Great! Now let's try removing the PSGallery1 repository and updating a module:
Unregister-PSRepository PSGallery1
Update-Module -Name pester -Force
Success! The module updated without error.
I'm not sure what is broken here, the URL for the PSGallery repository or Install-Package, but reinstalling all modules that were installed from the old URL seems to fix everything.
After trying all kinds of things, forcing a reinstall of the NuGet package provider seems to have cleared up the issue with Update-Module for me.
Execute this in an elevated PowerShell session:
Install-PackageProvider Nuget –Force
For reference, I was here when I had my best success:
https://learn.microsoft.com/en-us/powershell/scripting/gallery/installing-psget
I had the same problem and found this question. I tried everything that Jason Boyd (above) wrote about, but it did not work.
Searched some more and found this link https://community.spiceworks.com/topic/2265662-powershell-get-download-problem
where it said TLS 1.0 could be the culpit. It suggests running
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After that, I was able to update my packages.
The combination of the above answers fixed it for me.
PS> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS> Install-PackageProvider Nuget –Force
PS> Install-Module -Name PSWindowsUpdate
You may need to remove the old version of PSWindowsUpdate first to install the new version.
You can do a -force and it would install two versions side-by-side, but that probably isn't the best idea.
I have the same problem with Windows Powershell 5.1.17134.407 and also tested on the same machine on PowerShell 6.1. Update-Module works as expected with PowerShell 6.1 with the same version of the PowerShellGet module in both Windows PowerShell and PowerShell. So, it looks like the problem is unique to Windows PowerShell and making a guess without further testing, is a problem within the Update-Module code in the PowerShellGet module itself when running on Windows PowerShell.
I don't have a solution for you using Update-Module but as a work around you can use Install-Module instead with the -AllowClobber parameter. It does not fail with this error like Update-Module does. And, right now at least, the end result will be the same since Update-Module actually just installs a new version side-by-side with any older version(s) that are installed per my testing and per https://github.com/PowerShell/PowerShellGet/issues/213.
...
After doing some further testing I happened to reboot the system I was testing on. After reboot the issue with Update-Module in Windows PowerShell 5.1 was resolved - Update-Module now works as expected. I cannot say for sure that the reboot is what resolved it, but it is now resolved.
I tried this but i did get the PSGaller2 thing going.
So i looked further for a sollution. Since i am in a VPN / Proxy envirenmont i did not get the updated to work. When i dit this it worked for me.
$webclient=New-Object System.Net.WebClient
$webclient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
I found similar issue. In my case, it was happening due to TLS.
I followed below steps to resolve the issue as follows:
1. Set strong cryptography on 64 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type Dword
set strong cryptography on 32 bit .Net Framework (version 4 and above)
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type Dword
Restart PS console
Check for supported protocols by using[Net.ServicePointManager]::SecurityProtocol
Register Default Register-PSRepository -Default
Try this:
[System.Net.WebRequest]::DefaultWebProxy.Credentials = System.Net.CredentialCache]::DefaultCredentials
get-psrepository
register-psrepository -default
Fix:
Install-Module -Name PowershellGet -Repository PSGallery -Force
Close the existing PowerShell or ISE session and start a new one
Update-Module
For me these is the code that worked:
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
$env:Path += ";C:\ProgramData\chocolatey\bin"

Warning while install-module PowerShellGet

While installing PowerShellGet, I perform the following:
Install-PackageProvider Nuget –force –verbose
then I Exit, try running the following:
Install-Module –Name PowerShellGet –Force –Verbose
When I do this, I get the error:
This error occurs when I try to install other modules too, like MSOnline, Azure etc.
I have the latest version of Powershell and also the necessary modules.
I feel that the reason is due to the PowershellGet file.
Is there a way to resolve this issue?
You need to register the PowerShell repository before installing PowerShellGet. Try this
Register-PSRepository -Name “PSGallery” -SourceLocation “https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted