Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to import from path? #31

Closed
StingyJack opened this issue Jun 23, 2018 · 7 comments
Closed

How to import from path? #31

StingyJack opened this issue Jun 23, 2018 · 7 comments

Comments

@StingyJack
Copy link

I've saved this module to a folder and am trying to import it from that folder. What is the correct file to reference to import it?

I've tried pointing to the PSM1 and it doesnt load

PS C:\temp\psmsistuff> Import-Module .\msi\MSI\3.2.33\MSI.psm1
Unable to find type [Microsoft.Tools.WindowsInstaller.PowerShell.Module].
At C:\temp\psmsistuff\msi\MSI\3.2.33\MSI.psm1:191 char:1
+ [Microsoft.Tools.WindowsInstaller.PowerShell.Module]::Use()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Tools...werShell.Module:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

I've also tried importing the PSD1, and it loads but I dont see the commands referenced in the readme.

PS C:\temp\psmsistuff> Import-Module .\msi\MSI\3.2.33\MSI.psd1

PS C:\temp\psmsistuff> get-module

ModuleType Version    Name                                ExportedCommands                                                                                                                                                         
---------- -------    ----                                ----------------                                                                                                                                                         
<snip>
Script     0.0        MSI                                 {Get-MSIComponentState, Get-MSISharedComponentInfo, Install-MSIAdvertisedFeature}                                                                                        
<snip>

PS C:\temp\psmsistuff> get-command -Module msi
CommandType     Name                                               Version    Source                                                                                                                                               
-----------     ----                                               -------    ------                                                                                                                                               
Function        Get-MSIComponentState                              0.0        MSI                                                                                                                                                  
Function        Get-MSISharedComponentInfo                         0.0        MSI                                                                                                                                                  
Function        Install-MSIAdvertisedFeature                       0.0        MSI     

How can I import this from a specific folder that is not ever going to be in the $PSModulePath?

@heaths
Copy link
Owner

heaths commented Jun 25, 2018

Try help import-module (hint: try -path).

@StingyJack
Copy link
Author

There is no -Path parameter for import-module
image I load modules from filesystem paths often.

Like I said, I could import via the manifest file, but those functions in the Readme.md (get-msiproductinfo and get-msicomponentinfo) are not in the function list. So perhaps the psd1 is not the thing to point import-module at, or maybe the readme is grossly out of date.

@heaths
Copy link
Owner

heaths commented Jun 26, 2018

The README.md file is correct. I use this module often.

You can pass a path to the -Name parameter, or just update your $env:PSModulePath. Do not use the psm1. In general, always choose the psd1 if there is one.

@StingyJack
Copy link
Author

If the readme is correct, and I'm importing the psd1 without errors, why don't the functions in the readme show up when I run 'get-command' for this module?

@heaths
Copy link
Owner

heaths commented Jun 27, 2018

Not sure. Works fine on all my machines, and first I'm hearing of this. It's all standard authoring and hasn't changed in years. Could be an issue with the PowerShell configuration on your machine, but I have no idea what that could be.

PS> gcm -mod msi

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-MSIComponentState                              3.2.33     msi
Function        Get-MSISharedComponentInfo                         3.2.33     msi
Function        Install-MSIAdvertisedFeature                       3.2.33     msi
Cmdlet          Add-MSISource                                      3.2.33     msi
Cmdlet          Clear-MSISource                                    3.2.33     msi
Cmdlet          Edit-MSIPackage                                    3.2.33     msi
Cmdlet          Export-MSIPatchXml                                 3.2.33     msi
Cmdlet          Get-MSIComponentInfo                               3.2.33     msi
Cmdlet          Get-MSIFeatureInfo                                 3.2.33     msi
Cmdlet          Get-MSIFileHash                                    3.2.33     msi
Cmdlet          Get-MSIFileType                                    3.2.33     msi
Cmdlet          Get-MSILoggingPolicy                               3.2.33     msi
Cmdlet          Get-MSIPatchInfo                                   3.2.33     msi
Cmdlet          Get-MSIPatchSequence                               3.2.33     msi
Cmdlet          Get-MSIProductInfo                                 3.2.33     msi
Cmdlet          Get-MSIProperty                                    3.2.33     msi
Cmdlet          Get-MSIRelatedProductInfo                          3.2.33     msi
Cmdlet          Get-MSISource                                      3.2.33     msi
Cmdlet          Get-MSISummaryInfo                                 3.2.33     msi
Cmdlet          Get-MSITable                                       3.2.33     msi
Cmdlet          Install-MSIPatch                                   3.2.33     msi
Cmdlet          Install-MSIProduct                                 3.2.33     msi
Cmdlet          Measure-MSIProduct                                 3.2.33     msi
Cmdlet          Remove-MSILoggingPolicy                            3.2.33     msi
Cmdlet          Remove-MSISource                                   3.2.33     msi
Cmdlet          Repair-MSIProduct                                  3.2.33     msi
Cmdlet          Set-MSILoggingPolicy                               3.2.33     msi
Cmdlet          Test-MSIProduct                                    3.2.33     msi
Cmdlet          Uninstall-MSIPatch                                 3.2.33     msi
Cmdlet          Uninstall-MSIProduct                               3.2.33     msi


PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.112
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.112
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

@StingyJack
Copy link
Author

StingyJack commented Jun 27, 2018

I don't discount an environmental issue, visual studio recently forgot how to load modules from any of the 64bit ps module paths. In this case, my ps versions are all the same, however I dont get a Version number listed for the commands and the module lists as Script, and it seems like none of the Cmdlets are available.

Trying to locate the cmdlets in the dll's in the package isnt finding them either
image

Are there any assemblies that look to be missing from this folder?
image

@heaths
Copy link
Owner

heaths commented Jun 27, 2018

That's everything (and more; could of those files don't need to be in there and I'll remove). Run fuslogvw.exe from the .NET Framework SDK and see if there are binding errors.

heaths added a commit that referenced this issue Jun 27, 2018
Fixes se[arate issue discovered in #31
heaths added a commit that referenced this issue Jun 27, 2018
Fixes se[arate issue discovered in #31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants