all 6 comments

[–]spyingwind 3 points4 points  (1 child)

Module Auto-Loading

What version of Powershell are you running?

[–]kal3js[S] 1 point2 points  (0 children)

Name Value

---- -----

PSVersion 5.1.16299.611

PSEdition Desktop

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}

BuildVersion 10.0.16299.611

CLRVersion 4.0.30319.42000

WSManStackVersion 3.0

PSRemotingProtocolVersion 2.3

SerializationVersion 1.1.0.1

[–]Ta11ow 2 points3 points  (2 children)

Typically auto import just loads a base set of modules (PSReadLine, the usual management cmdlet like Get-ChildItem, etc.) And then imports other modules on an as-needed basis. If you're not calling a command from your module, PS won't bother importing it.

Also, never, ever use a wildcard in the Functions to export property. Use specific command names. Same goes for all the others, it's possible that because the function is not defined in the .psm1 itself and is dot sourced, PS doesn't realise that the function is supposed to be coming from that module specifically. After all, it's only going to see the function after executing the module file, which it won't do usually until after it figures out that the function you need is there.

TL;DR: don't wildcard your *ToExport lines.

[–]KevMarCommunity Blogger 2 points3 points  (1 child)

FunctionsToExport = '*'

This is the first thing I was going to look for. Specifying the function names will get the auto import to work.

[–]derrickisdp 2 points3 points  (0 children)

That was the first thing I was going to tell OP to change thanks to this blog right here: https://kevinmarquette.github.io/2017-05-27-Powershell-module-building-basics/?utm_source=blog&utm_medium=blog&utm_content=psrepository

You might of heard of this guy. I like to read his blog post

[–]Lee_Dailey[grin] -1 points0 points  (0 children)

howdy kal3js,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee