Cannot find an overload for "SoftwareIdentity" - powershell

I'd like to use functionality from the latest Azure Powershell library but I'm struggling to install it. This is on an AWS x64 Windows 2012 R2 Standard server.
I get the following error
PS C:\Users\Administrator> Install-Module -Name AzureAD
WARNING: Cannot find an overload for "SoftwareIdentity" and the argument count: "17".
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'AzureAD'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:1809 char:21
+ $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
This is with PSVersion = 4.0
Get-Module shows: 3.1.0.0 Microsoft.PowerShell.Management, 3.1.0.0 Microsoft.PowerShell.Utility Script, 1.1.1.0 PackageManagement Script, 1.1.2.0 PowerShellGet
Get-PSRepository shows PSGallery Untrusted https://www.powershellgallery.com/api/v2/
Do you have any pointers to help troubleshoot / fix please?
Thanks

Ok so I installed Win8.1AndW2K12R2-KB3134758-x64.msu from https://www.microsoft.com/en-us/download/details.aspx?id=50395
Now Get-Module returns nothing and the first time I tried Install-Module -Name AzureAD it moaned about the -Name parameter. Second time (which I'm assuming means I'm imagining the first time) it worked. Now to see if I can add a user to an Azure AD group using the latest OpenICF connector scripts.

Related

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.

Powershell won't install almost any module using install-module

My Powershell v5.1 won't install almost any module automatically using install-module whereas manually installation does work.
First, when I run install-module, it would download the module then throw an error, say the pscx module:
PackageManagement\Install-Package : Package 'Pscx' failed to be installed because: Specified cast is not valid.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:9307 char:21
+ ... $null = PackageManagement\Install-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (Pscx:String) [Install-Package], Exception
+ FullyQualifiedErrorId : Package '{0}' failed to be installed because: {1},Microsoft.PowerShell.PackageManag
ement.Cmdlets.InstallPackage
What I can do now is to manually download the module and use import-module myself. The error occurs almost every time when I'm trying to install any module through this cmdlet. How can I address this problem?
For troubleshooting, Get-PSRepository gives me this:
PS C:\> Get-PSRepository
Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Trusted https://www.powershellgallery.com/api/v2
GalleryRolling Trusted https://www.poshtestgallery.com/api/v2/
EDIT:
Got the same error when trying to use Save-Module:
PS C:\> Find-Module -Name 'pscx' | Save-Module -Path "G:\Temp\System Documents\WindowsPowerShell\Modules"
WARNING: Package 'Pscx' failed to be installed because: Specified cast is not valid.
WARNING: Package 'Pscx' failed to install.
PackageManagement\Save-Package : Unable to save the module 'Pscx'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:11331 char:25
+ ... $null = PackageManagement\Save-Package #PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...ets.SavePackage:SavePackage) [Save-Packag
e], Exception
+ FullyQualifiedErrorId : ProviderFailToDownloadFile,Microsoft.PowerShell.PackageManagement.Cmdlets.Save
Package
It downloaded the package then displays the WARNING.
When using the Find-Module alone, the result is:
PS C:\> Find-Module -Name 'pscx'
Version Name Repository Description
------- ---- ---------- -----------
3.3.2 Pscx PSGallery PowerShell Community Extensi...
EDIT 2:
Oh I forgot to say that there are no files created in the specific download folder after the download process bar disappeared. Does that mean the download has failed?
EDIT 3: #Sage Pourpre
Debugging log
I Always run PS as administrator.
-Scope CurrentUser throws the same error.
Both PS C:\> Uninstall-Module -Name "PowerShellGet" and PS C:\> Uninstall-Script -Name "PowerShellGet" -RequiredVersion 2.0.3 produce the same result.
PackageManagement\Uninstall-Package : No match was found for the specified search criteria and script names
'PowerShellGet'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:12343 char:21
... $null = PackageManagement\Uninstall-Package #PSBoundParameters
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstal
l-Package], Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage
Then I tried to list available modules:
PS C:\> Get-Module -ListAvailable
Directory: G:\Temp\System Documents\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 2.7.1.7 ISESteroids {Get-PSSharperData, Add-SteroidsContextMenuComma...
Script 1.2 Use-RawPipeline {Invoke-NativeCommand, Receive-RawPipeline, Get-...
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValida...
Script 1.2.4 PackageManagement {Find-Package, Get-Package, Get-PackageProvider,...
Script 4.5.0 Pester {Describe, Context, It, Should...}
Script 2.0.4 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Fi...
Script 2.0.3 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Fi...
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHand...
Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-...
Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-AppLockerPoli...
Manifest 1.0.0.0 AppvClient {Add-AppvClientConnectionGroup, Add-AppvClientPa...
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPacka...
Script 1.0.0.0 AssignedAccess {Clear-AssignedAccess, Get-AssignedAccess, Set-A...
Manifest 1.0.0.0 BitLocker {Unlock-BitLocker, Suspend-BitLocker, Resume-Bit...
etc...
And Get-InstalledModule
PS C:\> Get-InstalledModule -Name "PowerShellGet" -RequiredVersion 2.0.3
PackageManagement\Get-Package : No match was found for the specified search criteria and module names
'PowerShellGet'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:9050 char:9
+ PackageManagement\Get-Package #PSBoundParameters | Microsoft. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...lets.GetPackage:GetPackage) [Get-Package],
Exception
+ FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage
Finally solved by:
[Net.ServicePointManager]::SecurityProtocol = "tls12"
The solution is from the following blog posted by vanBrenk:
Trying to install a PowerShell module behind a proxy? Chances are you're getting this error: "Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'". Turns out it isn't allowed through your proxy server [...] Now every command you run is sent and allowed through the proxy.
If you are just using the default repo, there is not reason to specify it.
Try it this way...
Find-Module -Name 'pscx' |
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
Install-Module -Name 'pscx'
You can have multiple version of PowerShell on the same site, it should not impact installing modules, generally.

PowerShell windows 2008 missing modules

I apologize if this is a NOOB question but I wrote a PowerShell script on my windows 10 box and I am trying to run the script on a 2008 box. On the new install of the 2008 box I had to add the windows powershell feature. My end goal is to install the Web Server (IIS) Administration Cmdlets
PS C:\Users\Administrator> Get-Module -ListAvailable | Import-Module
PS C:\Users\Administrator> Get-Module -ListAvailable
ModuleType Name ExportedCommands
---------- ---- ----------------
Manifest BitsTransfer {}
Manifest PSDiagnostics {Enable-PSTrace, Enable-WSManTrace, Start-Trace, Disable-PSWSManCombined...
PS C:\Users\Administrator>
PS C:\Users\Administrator> add-pssnapin WebAdministration
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2.
At line:1 char:13
+ add-pssnapin <<<< WebAdministration
+ CategoryInfo : InvalidArgument: (WebAdministration:String) [Add-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
PS C:\Users\Administrator>
PS C:\Users\Administrator> Import-Module WebAdministration
Import-Module : The specified module 'WebAdministration' was not loaded because no valid module file was found in any module directory.
At line:1 char:14
+ Import-Module <<<< WebAdministration
+ CategoryInfo : ResourceUnavailable: (WebAdministration:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId :Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Any ideas?
You need to install the IIS managment tools before the WebAdministration-module is available. Try (tested on Win10):
Enable-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerManagementTools" -All
Windows Server 2008 doesn't come with a PowerShell module for managing IIS. That feature was added with Windows Server 2008 R2. You need to download and install it first. See here for further information. See also this related question.

How to install documentation for 7zip4PowerShell

After installing the 7zip4PowerShell module, if I call Get-Help on any of its cmdlets, I get the message
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
-- To download and install Help files for the module that includes this cmdlet, use Update-Help.
If I call update-help by itself, it doesn't change anything.
If I call update-help -Module 7zip4PowerShell, I get the following:
PS C:\windows\system32> update-help -Module 7zip4PowerShell
update-help : Failed to update Help for the module(s) :
'7Zip4Powershell'
The HelpInfoURI https://github.com/thoemmi/7Zip4Powershell does not start with HTTP.
At line:1 char:1
+ update-help -Module 7zip4PowerShell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (HelpInfoUri:Uri) [Update-Help], Exception
+ FullyQualifiedErrorId : InvalidHelpInfoUriFormat,Microsoft.PowerShell.Commands.UpdateHelpCommand
What am I doing wrong?