1

I can not install the module pointing to the PSM1 file

Is it possible to install a .PSM1 module? With the Install-Module command I can not do it.

If it is not possible, how do I not have to import the module with Import-Module in all new sections.

Install-Module "\\servers\folders\module.PSM1"

Error Example:

Install-Module "C:\INFRA\PsSinqia.psm1"
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'C:\INFRA\PsSinqia.psm1'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Packag
   e], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Ivo Jesus
  • 35
  • 1
  • 1
  • 9
  • Please add more detail. What do you mean "cannot install"? Why not? Do you get errors? Consider that we cannot read your screen and see what you see. If there are errors, edit your question and post the entire error. If there are not, explain _in detail_ what is happening and what you expect to happen. – Avery Mar 28 '19 at 18:11
  • The install module function does not accept the path as parameter. I need to know if there's any other way to do this. Or to "persist" the import of the module. – Ivo Jesus Mar 28 '19 at 18:23
  • 1
    The [`PsGet` module](https://github.com/psget/psget/) allows installing modules from a local path using `-ModulePath` parameter. Import it as `Import-Module PSGET -prefix GH` (use a prefix by your own preference) to prevent mixing cmdlet names with those from the `PowerShellGet` module. – JosefZ Mar 28 '19 at 19:54
  • But with Import-Module do I need to do this with every new section of Powershell, or will it be necessary to import a single time, and even after restarting the PC, will the module commands be available? – Ivo Jesus Mar 28 '19 at 20:02
  • Simply add `Import-Module PSGET -prefix GH` to `$profile.CurrentUserAllHosts` or to `$profile.AllUserAllHosts`. – JosefZ Mar 28 '19 at 20:19
  • Can you show me an example? To import, I imagine it to be: Import-Module "C:\INFRA\PsSinqia.psm1" -prefix Sq But I do not know how to apply this to the paths that you have passed – Ivo Jesus Mar 28 '19 at 20:49
  • I think you might be confusing 'installing' a module with 'importing' one. If you place the PSM1 file in the correct place ([somewhere on PsModulePath](https://learn.microsoft.com/en-us/powershell/developer/module/installing-a-powershell-module#install-modules-in-psmodulepath)), PowerShell will find and use the module automatically when needed - no call to `Import-Module` required. – boxdog Mar 29 '19 at 09:00
  • Did not work, Do I need to have any manifests or is it possible only with PSM1? – Ivo Jesus Mar 29 '19 at 13:25
  • I find a way in https://stackoverflow.com/questions/16018732/msonline-cant-be-imported-on-powershell-connect-msolservice-error Thanks – Ivo Jesus Apr 02 '19 at 19:33

1 Answers1

1

The correct folders are:

  • C:\Windows\System32\WindowsPowerShell\v1.0\Modules\
  • C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\

The folder and module must have the same name.

Reference: MSOnline can't be imported on PowerShell (Connect-MsolService error)

Ivo Jesus
  • 35
  • 1
  • 1
  • 9