PowerShell 7.0 Install-Module fails

Windows 2019 Server PowerShell Core 7.0
Trying to install the openssh powershell commandlets.

PS C:\Users\thomas.ssh> Install-Module -Force OpenSSHUtils -Scope AllUsers
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The module ‘OpenSSHUtils’ cannot be installed or updated because the authenticode signature of the file
| ‘OpenSSHUtils.psd1’ is not valid.

PS C:\Users\thomas.ssh>

I need this command
Repair-AuthorizedKeyPermission

Any ideas

Thank you

Tom

Do exactly as the comment on this page says. Download the nuget package, extract it, and import it. It worked for me.

https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1

Import-Module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1
Get-Command -Module OpenSSHUtils

CommandType   Name                           Version  Source
-----------   ----                           -------  ------
Function      Enable-Privilege               1.0.0.1  OpenSSHUtils
Function      Get-UserAccount                1.0.0.1  OpenSSHUtils
Function      Get-UserSID                    1.0.0.1  OpenSSHUtils
Function      Repair-AuthorizedKeyPermission 1.0.0.1  OpenSSHUtils
Function      Repair-FilePermission          1.0.0.1  OpenSSHUtils
Function      Repair-SshdConfigPermission    1.0.0.1  OpenSSHUtils
Function      Repair-SshdHostKeyPermission   1.0.0.1  OpenSSHUtils
Function      Repair-UserKeyPermission       1.0.0.1  OpenSSHUtils
Function      Repair-UserSshConfigPermission 1.0.0.1  OpenSSHUtils

Doug,

What do I do with a file type of nupkg ? I did a manual download from the site. gave me opensshutils.1.0.0.1.nupkg.

I then found this
https://www.powershellgallery.com/packages/OpenSSHUtils/0.0.2.0/Content/OpenSSHUtils.psd1

Copy and pasted it

PS C:> Install-Module c:\temp\opensshutils.psd1
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No match was found for the specified search criteria and module name ‘c:\temp\opensshutils.psd1’. Try
| Get-PSRepository to see all available registered module repositories.

PS C:>

I am on PowerShell 7.0

Doug,

I was able to extract the file

PS C:> Install-Module c:\temp\opensshutils\opensshutils.psd1
Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 | … talledPackages = PackageManagement\Install-Package @PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No match was found for the specified search criteria and module name
| ‘c:\temp\opensshutils\opensshutils.psd1’. Try Get-PSRepository to see all available registered module
| repositories.

Same results
PS C:> $PSVersionTable

Name Value


PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

PS C:>

Is my powershell current?

Tom, I use 7-zip to extract. You want to import the PSD1 like I showed in my command. Give that a shot, it should work.

Tom, there is a newer version. Here is what I imported with.

PSVersion 7.1.0-preview.2
PSEdition Core
GitCommitId 7.1.0-preview.2
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

It also imported fine in 5.1 Extract the nuget package to a folder like in my example I extracted to C:\temp\opensshutils.1.0.0.1\ and then ran the command.

Import-module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1

Of course you can specify the scope if you need and use -force if required. This should work, but NOT the command below

import-module OpenSSHUtils

Because that is just going to try and find it in the repository - it is not the version you downloaded.

Doug

I renamed my folder to opensshutils.1.0.0.1
Then ran your command

Import-module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1
and it came back with no errors. I then tested the comdlet I needed and it worked. I think the error message was just information before not sure

PS C:\ProgramData\ssh> Import-module C:\temp\opensshutils.1.0.0.1\OpenSSHUtils.psd1
PS C:\ProgramData\ssh>
PS C:\ProgramData\ssh> Repair-AuthorizedKeyPermission

cmdlet Repair-AuthorizedKeyPermission at command pipeline position 1
Supply values for the following parameters:
FilePath:

PS C:\Users\thomas.ssh> get-command -module opensshutils

CommandType Name Version Source


Function Enable-Privilege 1.0.0.1 OpenSSHUtils
Function Get-UserAccount 1.0.0.1 OpenSSHUtils
Function Get-UserSID 1.0.0.1 OpenSSHUtils
Function Repair-AuthorizedKeyPermission 1.0.0.1 OpenSSHUtils
Function Repair-FilePermission 1.0.0.1 OpenSSHUtils
Function Repair-SshdConfigPermission 1.0.0.1 OpenSSHUtils
Function Repair-SshdHostKeyPermission 1.0.0.1 OpenSSHUtils
Function Repair-UserKeyPermission 1.0.0.1 OpenSSHUtils
Function Repair-UserSshConfigPermission 1.0.0.1 OpenSSHUtils

I am happy now it is installed do not know how it did but it is

Thank you
This is now resolved.

Hi Tom,

That means it imported successfully and is also how the commands were available. Now keep in mind if you are needing this in any automated script or another PC/powershell scope - these environments would also need to be able to import that module. Glad to hear it allowed you to resolve the Invoke-Command issue. Please be sure to check out this post to see how to properly format your code in the forum, it’d make it easier for folks like me to help you if you can follow a few guidelines. Take care!