2017-09-12 5 views
3

ODBCManager라는 이진 Powershell 모듈을 만들었습니다. 피드에서 설치 한 후 기능을 성공적으로 사용할 수 있지만 Get-Module은 이름으로 찾을 수 없습니다 (Get-Module -Name ODBCManager은 null을 반환합니다). Get-Module -ListAvailable은 2 분 쿼리 후에 표시되므로 확실히 설치됩니다. 또한 설치시 -Verbose에 성공이 표시됩니다.Powershell 이진 모듈을 찾을 수 없지만 설치되었습니다.

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'. 
  • 나는 그것이 폴더 이름과 DLL 이름이 같은
  • 매니페스트는
  • 기능 수출을 생성하고 예상대로 실행되어 있으며,
  • 에이 게시 피드 PowerShell은 모듈에서 PROGET에서 호스팅이

매니페스트 :

@{ 
    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' 
     } 
    } 
} 

내가 깜빡 했니? 왜냐하면 나는 모든 것을 시도했기 때문입니다.


편집 : @BenH의 도움 후 나는 더 연구 할 수 있었다 당신이 신속하게 모듈을 가져 설치,하지만 보여 Get-Module -ListAvailable -Name ODBCManager를 호출 할 수 있습니다 발견했다. - 나중에 참조 할 수 있도록!

답변

2

Install-ModuleImport-Module은 다릅니다. Get-Module은 가져온 모듈을 모두 반환하고 Get-Module -ListAvailable은 설치된 모든 모듈을 반환합니다.

따라서 모듈은 "설치"되었지만 "가져 오기"되지 않았습니다.

이후 버전의 PowerShell에서는 함수/cmdlet이 .psd1의 내 보낸 함수/cmdlet에 정의되어 있으면 동적으로 모듈을 가져옵니다. 그러나 수입 될 때까지 Get-Module은 그들을 나열하지 않을 것입니다.

이 시도 :

Import-Module ODBCManager 
Get-Module ODBCManager 
+0

아, 그래! 고마워요 :) - 정말 이상한 함수들이 여전히 임포트되지 않고 동작합니다 .. – HyTC

+1

@HyTC 함수를 호출 할 때, PowerShell은 동적으로 모듈을 임포트하기 때문에 작동합니다. PowerShell 1 & 2에서는 이런 일이 발생하지 않았습니다. – BenH

관련 문제