简体   繁体   English

Powershell二进制模块未找到但已安装

[英]Powershell Binary Module not found but installed

I've created a Binary Powershell Module called ODBCManager. 我创建了一个名为ODBCManager的二进制Powershell模块。 After installing from a feed, I am able to use it's functions successfully, but Get-Module does not find it by name ( Get-Module -Name ODBCManager returns null). 从feed安装后,我能够成功使用它的函数,但是Get-Module没有按名称找到它( Get-Module -Name ODBCManager返回null)。 Get-Module -ListAvailable will show it after a 2 minute query, so it's definitely installed. Get-Module -ListAvailable将在2分钟查询后显示它,因此它肯定已安装。 Also -Verbose on installation says success. 另外-Verbose安装说成功。

C:\Users\xxxxx> Get-Module -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.1      Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary     0.1.0.1    ODBCManager                         {Add-OracleODBC, Get-ODBCDrivers, New-OracleODBC}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     3.4.0      Pester                              {Describe, Context, It, Should...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove-PSReadlineKeyHandler, Get-PSReadlineOption...}
Manifest   20.0       SqlServer                           {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}


    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0.0.0    ActiveDirectory                     {Add-ADCentralAccessPolicyMember, Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPolicy, Add-ADFineGrainedPasswordPolicySu... Manifest   1.0.0.0    AppBackgroundTask                   {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroundTaskResourcePolicy, Unregister-AppBackgroundTask...} Manifest   2.0.0.0    AppLocker                           {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest   1.0.0.0    AppvClient                          {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}
Manifest   2.0.0.0    Appx                                {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script     1.0.0.0    AssignedAccess                      {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest   1.0        BestPractices                       {Get-BpaModel, Get-BpaResult, Invoke-BpaModel, Set-BpaResult}

......................


    Directory: C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0        SQLASCMDLETS                        {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest   1.0        SQLPS                               {Backup-SqlDatabase, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Disable-SqlAlwaysOn...}


    Directory: C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   2.0        SQLASCMDLETS                        {Add-RoleMember, Backup-ASDatabase, Invoke-ASCmd, Invoke-ProcessCube...}
Manifest   1.0        SQLPS                               {Add-SqlColumnEncryptionKeyValue, Complete-SqlColumnMasterKeyRotation, Get-SqlColumnEncryptionKey, Get-SqlColumnMasterKey...}


C:\Users\xxxxxx> Install-Module -Name ODBCManager -Scope AllUsers -Force -ErrorAction Stop -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '2' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '1' more times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/' for '0' more times
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Total package yield:'0' for the specified package 'ODBCManager'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://srv-proget/nuget/QASolutions-PS/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'ODBCManager'.
VERBOSE: Performing the operation "Install-Module" on target "Version '0.1.0.1' of module 'ODBCManager'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'ODBCManager' with version '0.1.0.1' from the repository 'http://srv-proget/nuget/QASolutions-PS/'.
VERBOSE: Searching repository 'http://srv-proget/nuget/QASolutions-PS/FindPackagesById()?id='ODBCManager'' for ''.
VERBOSE: InstallPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxxx\AppData\Local\Temp\191916'
VERBOSE: DownloadPackage' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916\ODBCManager\ODBCManager.nupkg',
uri='http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'
VERBOSE: Downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'http://srv-proget/nuget/QASolutions-PS/package/ODBCManager/0.1.0.1'.
VERBOSE: Completed downloading 'ODBCManager'.
VERBOSE: Hash for package 'ODBCManager' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='ODBCManager', version='0.1.0.1',destination='C:\Users\xxxxxx\AppData\Local\Temp\191916'
VERBOSE: Catalog file 'ODBCManager.cat' is not found in the contents of the module 'ODBCManager' being installed.
VERBOSE: For publisher validation, current module 'ODBCManager' with version '0.1.0.1' with publisher name ''. Is this module signed by Microsoft: 'False'.
VERBOSE: For publisher validation, using the previously-installed module 'ODBCManager' with version '0.1.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1' with publisher name ''. Is  this module signed by Microsoft: 'False'.
VERBOSE: Module 'ODBCManager' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\ODBCManager\0.1.0.1'.
  • I have it hosted in ProGet under a Powershell Modules Feed 我把它托管在一个Powershell Modules Feed的ProGet中
  • On Publish, folder name and DLL name are the same 在发布时,文件夹名称和DLL名称是相同的
  • Manifest has been created 清单已经创建
  • Functions export and execute as expected 函数按预期导出和执行

Manifest: 表现:

@{
    RootModule = 'ODBCManager.dll'
    ModuleVersion = '0.1.0.1' # filled in by cake-build process
    CmdletsToExport = '*'
    GUID = 'xxx-xxx-xxx-xx-xx'
    DotNetFrameworkVersion = '4.0'
    Author = 'xxx'
    Description = 'PowerShell Binary Module for manipulating ODBCs.'
    CompanyName = 'xxx'
    Copyright = '(c) 2017 xxx. All rights reserved.'
    PrivateData = @{
        PSData = @{
            ProjectUri = 'xxxxxxxxxx'
            LicenseUri = ''
            ReleaseNotes = 'First Release'
        }
    }
}

Have I forgot something? 我忘记了什么吗? Because I've tried everything. 因为我已经尝试了一切。


EDIT: After help from @BenH I was able to research further and found you can call Get-Module -ListAvailable -Name ODBCManager to quickly show your module installed, but not imported. 编辑:在@BenH的帮助下,我能够进一步研究,发现你可以调用Get-Module -ListAvailable -Name ODBCManager来快速显示已安装的模块,但不能导入。 -- For future reference! - 供将来参考!

Install-Module and Import-Module are different. Install-ModuleImport-Module是不同的。 Get-Module returns all of the Modules that are imported and Get-Module -ListAvailable returns all of the modules that are installed. Get-Module返回导入的所有模块, Get-Module -ListAvailable返回所有已安装的模块。

Thus your module is "Installed" but not "Imported". 因此,您的模块是“已安装”但不是“已导入”。

With later versions of PowerShell, modules are dynamically imported if their functions/cmdlets are defined in the exported functions/cmdlets of the .psd1. 对于PowerShell的更高版本,如果在.psd1的导出函数/ cmdlet中定义了函数/ cmdlet,则会动态导入模块。 But until they are imported, Get-Module will not list them. 但是在导入它们之前, Get-Module不会列出它们。

Try this: 尝试这个:

Import-Module ODBCManager
Get-Module ODBCManager

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM