Face difficulties on registering the SitecoreGallery repository - powershell

Want to install Sitecore9.1, first of all, try to register the repository in PowerShell.After running the following command get an error. Why error raise? need help to resolve this issue.
Register-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2
Error:
PackageManagement\Register-PackageSource : Module Repository 'SitecoreGallery' exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4173 char:17
+ ... $null = PackageManagement\Register-PackageSource #PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-Pack
ageSource], Exception
+ FullyQualifiedErrorId : PackageSourceExists,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource

The error says that this repository already exists. First, check if it's registered properly:
PS C:\> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2/
SitecoreGallery Untrusted https://sitecore.myget.org/F/sc-powershell/api/v2
If it is registered with incorrect data, you can change it:
Set-PSRepository -Name SitecoreGallery -SourceLocation https://sitecore.myget.org/F/sc-powershell/api/v2

Related

PowerShell Exchange online - Download

Where can I download Exchangeonline?
I am unable to use PowershellGet or NuGet as the proxy won't allow download via PS.
I get the below error.
PS C:\Windows\system32> find-module exchangeonline
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires
'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags.
At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to
see if the provider exists on the system.
At C:\Program Files (x86)\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 char:21
+ ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider
The correct name is ExchangeOnlineManagement
Find-Module ExchangeOnlineManagement
You can try running it like this to ensure any proxy authentication is passed to the command:
[System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
Find-Module ExchangeOnlineManagement
Failing this, you can manually download the package from PSGallery - https://www.powershellgallery.com/packages/ExchangeOnlineManagement/3.0.0 and install it manually - https://learn.microsoft.com/en-us/powershell/scripting/gallery/how-to/working-with-packages/manual-download?view=powershell-7.3

Can't install Exchange Online PowerShell V2 module

I'm trying to enable modern authentication for an O365 tenant, and then instructions say to import the Exchange Online Management module. I don't have that module, so those same instructions say to install it by using
Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.5
But then I get this error
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'ExchangeOnlineManagement'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], E
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Just in case I did also run this to check
Get-PSRepository
And the result was
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
And that seems correct. So does anybody know why it's not working.
Thanks!
Just replying with the answer in case it helps anyone else who stumbles across this in future. It was a TLS issue, and the fix was simply:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
After that everything worked as it should.

Powershell error saying the gallery is unavailable try again later

I am running into this issue where iam unable to install any modules. even when i try to register i get this error. any ideas on resolving this appreciate it.
PS C:\Users\abc> Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4095 char:9
+ Get-PSGalleryApiAvailability -Repository $Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
+ FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability
Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1
+ Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
PS C:\Users\abc> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.858
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.858
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
-- adding some more commands
Find-PackageProvider -Name nuget
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Find-PackageProvider : No match was found for the specified search criteria and package name 'nuget'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-PackageProvider -Name nuget
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:FindPackageProvider) [Find-PackagePro
vider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvid
er
Register seems to complete without any errors, but nothing gets added
PS C:\Users\abc> Register-PSRepository -Default
PS C:\Users\abc> Get-PSRepository
WARNING: Unable to find module repositories.
PS C:\Users\abc>
PS C:\Users\abc> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\Users\abc> Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4095 char:9
+ Get-PSGalleryApiAvailability -Repository $Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
+ FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability
Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1
+ Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
PS C:\Users\abc> Get-PSRepository
WARNING: Unable to find module repositories.
Try forcing tls 1.2. This solves most powershell gallery issues
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Not really a solution, but rather an FYI piece.
This also seems to happen regularly every three months now when TLS cert in https://www.powershellgallery.com/api/v2 expires. For some reason, Microsoft are struggling to get the cert renewal to work properly.
When this happens, none of the above mentioned solutions will work.
In fact, this is happening right now, as I type this...
https://github.com/PowerShell/PowerShellGallery/issues/166
To see if the issue is caused by the expired (or otherwise invalid) cert, just open this URL https://www.powershellgallery.com/api/v2 in a browser and see if the browser complains about the certificate.
If you need to make it work just this one time, you can try tricking Powershell into ignoring invalid certificates like so:
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};
...but be warned:
a) this is a bad practice and you shouldn't really have it as a permanent solution because this will expose you to man-in-the-middle attack; and
b) this may not help you because Microsoft guys usually disable PSGallery API when this situation happens. To check if the API is disabled right now, run:
# Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4302 char:9
+ Get-PSGalleryApiAvailability -Repository $Name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
+ FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability
Update:
Also look here for any current ongoing issues with PSGallery:
https://github.com/PowerShell/PowerShellGallery/blob/master/psgallery_status.md
Actually forcing tls12 is not enough to solve, but, reading carefully to the error message said: Use 'Register-PSRepository -Default'
So I tried: register-psrepository -Default
PS C:\Windows\system32> register-psrepository -Default
PS C:\Windows\system32> get-psrepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2
And it solve the problem.

Accesstoken error when trying to conncet to SkypeOnlineConnector module in PowerShell

I'm trying to connect to sfb module in PowerShell but getting the following error
PS C:\windows\system32> import-module skypeonlineconnector
$sfbSession = New-CsOnlineSession
Import-PSSession $sfbSession
Please enter the user principal name (ex. User#Domain.Com): Myadminaccount
Result:
Get-CsAccessToken : One or more errors occurred.
At C:\Program Files\Common Files\Skype for Business Online\Modules\skypeonlineconnector\SkypeOnlineConnectorStartup.psm1:128 char:22
+ ... cessToken = Get-CsAccessToken -UserName $UserName -TargetUri $targetU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-CsAccessToken], AggregateException
+ FullyQualifiedErrorId : System.AggregateException,Microsoft.Rtc.Management.OnlineConnector.GetAccessToken
Then my colleague tried on the same machine but it works fine with him.
I searched for an answer on the internet but no luck, all the answers I found them refers to either update the skype module or disabling the MFA. But we both (me and my colleague) have the same settings.
Can anyone knows where is the problem, does it has anything to do with my admin account are missing some permissions?
Below is my sfb module version:
PS C:\windows\system32> Get-Module -name SkypeOnlineConnector
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 7.0.0.0 skypeonlineconnector {New-CsOnlineSession, Set-WinRMNetworkDelayMS}
Regards,

Issues with Registering PSRepository and Installing VMWare PowerCLI Module

My Setup: Windows 10.17134, PowerShell 5.1.17134.407
When trying to Register a new PSRepository using the Code below….
Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted
….it gives me the following error:
FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
I am not able to install the VMWare PowerCLI Module with this command:
Save-module -Name vmware.powercli -path c:\temp
….it gives me this error:
FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage
Here are the results of a days googling
I'm running
Register-PSRepository
-Name "PSGallery"
–SourceLocation "https://www.powershellgallery.com/api/v2/"
-InstallationPolicy Trusted
(multiline for clarity)
and I kept getting
Register-PSRepository : Use 'Register-PSRepository -Default' to
register the PSGallery repository. At line:1 char:1
+ Register-PSRepository -Name "PSGallery" –SourceLocation "https://www. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
+ FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
I assumed this was to do with proxy settings so I tried all of the various methods of setting the proxy in powershell to no avail.
Finally I ran
Get-PSRepository
and discovered that the repository was already registered, it was just untrusted
So I ran
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
The original reason I had for doIng this is because when I run
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
I get
Install-PackageProvider : No match was found for the specified search
criteria for the provider 'NuGet'. The package provider requires
'PackageManagement' and 'Provider' tags. Please check if the specified
package has the tags. At line:1 char:1
+ Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.PowerShel\u2026tallPackageProvider:InstallPackageProvider)
[Install-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
Unfortunately, making the repository trusted did no help with my issue
... and the original reason for doing this was so I could run
Install-Module -Name SqlServer -Force -Verbose -Scope CurrentUser
Which was failing (sorry no error message, it was so long ago)
After all my fiddling however, this statement now works without error.
Not sure if it was all the proxy config, or making NuGet trusted or both
I've been chasing this problem for days. I isolated it to Install-PackageProvider not being able to download:
Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
In my case, my company does not allow us to download DLLs from the internet without due process. I engaged due process and got an approved copy of the DLL. Then it needs to be placed here:
$env:ProgramFiles\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll
Note the version becomes a folder and is stripped from the name.
Manually doing so eliminates the need to run Install-PackageProvider. Some articles state that Import-PackageProvider is necessary to get PowerShell to recognise it. But, I did not need to do the Import. Just try Install-Module -Name SqlServer -Force again.