Import SQLServer module error?

Jan 21, 2010 at 2:06 AM

 

PS C:\Documents and Settings\Ronald Dameron> import-module $home\Documents\WindowsPowerShell\Modules\ShowMbrs
import-module $home\Documents\WindowsPowerShell\Modules\SQLServer
import-module $home\Documents\WindowsPowerShell\Modules\Agent
import-module $home\Documents\WindowsPowerShell\Modules\Repl
import-module $home\Documents\WindowsPowerShell\Modules\SSIS
import-module $home\Documents\WindowsPowerShell\Modules\SQLParser
Import-Module : The module to process 'ShowMbrs.psm1', listed in field 'NestedModules' of module manifest 'C:\Documents and Settings\Ro
nald Dameron\Documents\WindowsPowerShell\Modules\SQLServer\SQLServer.psd1' was not processed because no valid module was found in any m
odule directory.
At line:2 char:14
+ import-module <<<<  $home\Documents\WindowsPowerShell\Modules\SQLServer
    + CategoryInfo          : ResourceUnavailable: (SQLServer:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
 

I can import all modules except the SQLServer module.  Error thrown is below. What did I miss?  Hoping to use netbook for SQLSat#32. Thx.

 

 

PS C:\Documents and Settings\Ronald Dameron> import-module $home\Documents\WindowsPowerShell\Modules\ShowMbrs

import-module $home\Documents\WindowsPowerShell\Modules\SQLServer

import-module $home\Documents\WindowsPowerShell\Modules\Agent

import-module $home\Documents\WindowsPowerShell\Modules\Repl

import-module $home\Documents\WindowsPowerShell\Modules\SSIS

import-module $home\Documents\WindowsPowerShell\Modules\SQLParser

 

Import-Module : The module to process 'ShowMbrs.psm1', listed in field 'NestedModules' of module manifest 'C:\Documents and Settings\Ro

nald Dameron\Documents\WindowsPowerShell\Modules\SQLServer\SQLServer.psd1' was not processed because no valid module was found in any m

odule directory.

At line:2 char:14

+ import-module <<<<  $home\Documents\WindowsPowerShell\Modules\SQLServer

    + CategoryInfo          : ResourceUnavailable: (SQLServer:String) [Import-Module], FileNotFoundException

    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

 

get-module returns...

 

PS C:\Documents and Settings\Ronald Dameron> get-module

 

ModuleType Name                      ExportedCommands                                                           

---------- ----                      ----------------                                                           

Script     ShowMbrs                  {Get-ShowMbrs, Set-ShowMbrs, New-ShowMbrs, Get-GroupUser}                  

Script     Agent                     {Get-AgentTargetServerGroup, Get-AgentProxyAccount, Get-AgentJobSchedule...

Script     Repl                      {Get-ReplEnumSubscriptions2, Get-ReplPublisherMonitor, Get-ReplEnumPubli...

Script     SSIS                      {New-ISItem, Get-ISPackage, Get-ISItem, Copy-ISItemFileToSQL...}           

Binary     SQLParser                 {Test-SqlScript, Out-SqlScript}                  

 

Coordinator
Jan 21, 2010 at 2:25 AM

What does get-module -listAvailable return?

 

Jan 21, 2010 at 10:18 AM

 

BEFORE I COPIED MODULES TO C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules:
PS C:\Documents and Settings\Ronald Dameron> get-module -listAvailable
ModuleType Name                      ExportedCommands                                                           
---------- ----                      ----------------                                                           
Manifest   BitsTransfer              {}                                                                         
AFTER
PS C:\Documents and Settings\Ronald Dameron> get-module -listAvailable
ModuleType Name                      ExportedCommands                                                           
---------- ----                      ----------------                                                           
Script     adoLib                    {}                                                                         
Manifest   Agent                     {}                                                                         
Manifest   BitsTransfer              {}                                                                         
Manifest   Repl                      {}                                                                         
Manifest   ShowMbrs                  {}                                                                         
Manifest   SQLParser                 {}                                                                         
Manifest   SQLServer                 {}                                                                         
Manifest   SSIS                      {}                  
Then:
PS C:\Documents and Settings\Ronald Dameron> import-module ShowMbrs
import-module SQLServer
import-module Agent
import-module Repl
import-module SSIS
import-module SQLParser
No errors.
I think the issue was that I had put the modules in a non-standard location. 
The text README needs to be updated to match the DOCUMENTATION page.  
Also, putting the modules in another location other than the one above caused the issue, I think.  
I created my Modules folder using the directions contained in the about_modules help.
 1. Create a Modules directory for the current user if one does
           not exist. 
           To create a Modules directory, type:
               new-item -type directory -path $home\Documents\WindowsPowerShell\Modules     
After I copied the modules to C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules the import worked without issue.
I originally had the modules here: C:\Documents and Settings\Ronald Dameron\Documents\WindowsPowerShell\Modules
So, it looks like they have to be a certain place to issue the import-module command without supplying a path AND if you nest modules.
I'm just starting with V2 so does that make sense?
I did read both your README and the instructions on the Documentation page during this effort.
Kind of counter-intuitive that Microsoft has v1.0 in the Modules path for PowerShell v2.
Hope this helps.

BEFORE I COPIED MODULES TO C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules:

 

PS C:\Documents and Settings\Ronald Dameron> get-module -listAvailable

 

ModuleType Name                      ExportedCommands                                                           

---------- ----                      ----------------                                                           

Manifest   BitsTransfer              {}                                                                         

 

AFTER

 

PS C:\Documents and Settings\Ronald Dameron> get-module -listAvailable

 

ModuleType Name                      ExportedCommands                                                           

---------- ----                      ----------------                                                           

Script     adoLib                    {}                                                                         

Manifest   Agent                     {}                                                                         

Manifest   BitsTransfer              {}                                                                         

Manifest   Repl                      {}                                                                         

Manifest   ShowMbrs                  {}                                                                         

Manifest   SQLParser                 {}                                                                         

Manifest   SQLServer                 {}                                                                         

Manifest   SSIS                      {}                  

 

Then:

 

PS C:\Documents and Settings\Ronald Dameron> import-module ShowMbrs

import-module SQLServer

import-module Agent

import-module Repl

import-module SSIS

import-module SQLParser

 

 

No errors.

 

I think the issue was that I had put the modules in a non-standard location. 

The text README needs to be updated to match the DOCUMENTATION page.  

Also, putting the modules in another location other than the one above caused the issue, I think.  

 

I created my Modules folder using the directions contained in the about_modules help.

 

 1. Create a Modules directory for the current user if one does

           not exist. 

 

           To create a Modules directory, type:

 

               new-item -type directory -path $home\Documents\WindowsPowerShell\Modules     

 

It wasn't until I copied the modules to C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules the import worked without issue.

 

I originally had the modules here: C:\Documents and Settings\Ronald Dameron\Documents\WindowsPowerShell\Modules

 

So, it looks like they have to be a certain place to issue the import-module command without supplying a path AND if you nest modules.

 

I'm just starting with V2 so does that make sense?

 

I did read both your README and the instructions on the Documentation page during this effort.

 

Kind of counter-intuitive that Microsoft has v1.0 in the Modules path for PowerShell v2.

 

Hope this helps.

 

 

 

 

Coordinator
Jan 21, 2010 at 10:31 AM

You're right about modules needing to be in a specific location either user or system.  I've never specified a path for module import and I'm not aware that you can. I've tested the modules on a couple of machines both Vista and Windows 7, what OS are you using? If the module nesting is a problem you could get rid of it my modifying the module manifest (psd1 file) and then adding import-module showmbrs -force to the SQLServer module.

Coordinator
Jan 21, 2010 at 10:34 AM

One other thing. What does $env:psmodulepath return?

Jan 21, 2010 at 10:45 AM

 

PS C:\Documents and Settings\Ronald Dameron> $env:psmodulepath
C:\Documents and Settings\Ronald Dameron\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

I have a Dell Mini 10v running WinXP SP3. 

PS C:\Documents and Settings\Ronald Dameron> $env:psmodulepath

C:\Documents and Settings\Ronald Dameron\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

I think I see the issue now.
My modules were originally in C:\Documents and Settings\Ronald Dameron\Documents\WindowsPowerShell\Modules
not C:\Documents and Settings\Ronald Dameron\My Documents\WindowsPowerShell\Modules
I created the Modules folder using the example from the about_Modules help in PowerShell v2.
More from the about_Modules help.
To import a module that is not in a default module location, use the fully qualified path to the module folder in the command. For example, to add the TestCmdlets module in the C:\ps-test directory to your session, type: import-module c:\ps-test\TestCmdlets
I'm going to move the modules to the MY DOCUMENTS folder and try the import again.  It's working now in the system location.  Thx.

 

Coordinator
Jan 21, 2010 at 10:52 AM

Good to know about specifying a path. The path thing makes sense and explains why putting the module in your system module directory worked. I also noticed you can add temporary or permanent path to your psmodulepath http://msdn.microsoft.com/en-us/library/dd878326(VS.85).aspx

Jan 21, 2010 at 4:26 PM

I moved the modules from the system location to correct location in My Documents that is identified by the $env:psmodulepath.

Import-module works without issue.  Thx.

Thx.