![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Why do modules in the PSHome\Modules folder require the full p While it does turn out to be the way I've imported the library its not what you thought. In the case of the FileTransfer module; there really isn't one instead there is a *.psd1 file which points to a .NET Interop library. Turns out that if you import any library that via its manifest Powershell will require you provide the complete path if you are to do this Get-Command -Module <full path to module> However if you import it via is module file *.psm1 then it only requires the name of the module. I will update the bug report to reflect reality rather than confusion. thx bob "Kiron" wrote: Quote: > It has to do with the way you import the module, PS will assign that as the module's name while it's loaded. > It's not recommended to use the Module's fullpath when importing it, the extension gets stripped, that's the problem you bumped into. To avoid this pass the name of the module's main file w/o extension, it'll work even with the fullpath up to the extension, but you'll have to retrieve it with the almost fullpath: > > $full = "$pshome\Modules\FileTransfer\FileTransfer.psd1" > $fullNoExt = $full -replace '\.psd1$' > $name = 'FileTransFER' # <- last three chars capitalized > $full, $fullNoExt, $name | % { > $x = @" > write-host Starting... -f 14 > Import-Module $_ > gcm -Module $_ > (Get-Command Add-FileTransfer).ModuleName > write-host Exiting... -f 14 > "@ > $cmd = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($x)) > powershell -nop -enc $cmd > } > # $full ...problem you described, $fullNoExt works, so does $name, > # note the last three chars ...capitalized as it was imported > > -- > Kiron |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Why do modules in the PSHome\Modules folder require the full p I think I'm going to hide. Kiron you are correct again. This had nothing to do with a manifest file. The behavior I was complaining about is reproducible using a relative path which resolves to the current directory. import-module .\module.psm1 ## will require the module name to have the complete path import-module module.psm1 ## only requires the module name "Bob Landau" wrote: Quote: > While it does turn out to be the way I've imported the library its not what > you thought. > > In the case of the FileTransfer module; there really isn't one instead there > is a *.psd1 file which points to a .NET Interop library. > > Turns out that if you import any library that via its manifest Powershell > will require you provide the complete path if you are to do this > > Get-Command -Module <full path to module> > > > However if you import it via is module file *.psm1 then it only requires the > name of the module. > > I will update the bug report to reflect reality rather than confusion. > > thx > bob > > "Kiron" wrote: > Quote: > > It has to do with the way you import the module, PS will assign that as the module's name while it's loaded. > > It's not recommended to use the Module's fullpath when importing it, the extension gets stripped, that's the problem you bumped into. To avoid this pass the name of the module's main file w/o extension, it'll work even with the fullpath up to the extension, but you'll have to retrieve it with the almost fullpath: > > > > $full = "$pshome\Modules\FileTransfer\FileTransfer.psd1" > > $fullNoExt = $full -replace '\.psd1$' > > $name = 'FileTransFER' # <- last three chars capitalized > > $full, $fullNoExt, $name | % { > > $x = @" > > write-host Starting... -f 14 > > Import-Module $_ > > gcm -Module $_ > > (Get-Command Add-FileTransfer).ModuleName > > write-host Exiting... -f 14 > > "@ > > $cmd = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($x)) > > powershell -nop -enc $cmd > > } > > # $full ...problem you described, $fullNoExt works, so does $name, > > # note the last three chars ...capitalized as it was imported > > > > -- > > Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Modules days numbered? | .NET General | |||
| CTP2: Modules using PSD1? | PowerShell | |||
| RAM Memory Modules Incorrectly Detected ? | Vista hardware & devices | |||
| Unable to see all modules | PowerShell | |||
| Rebuild all modules under vista? | Vista General | |||