A question came up about the behavior of what’s that?).

So What’s the Question?

Does the auto-loading of modules in PowerShell Version 3 use Import-Module behind the scenes?  If it does, can we use default parameter sets to control what types of things are imported?

What Actually Happens?

So, it turns out that default parameter set (new feature) can be used to customize the import of new modules.

$PSDefaultParameterValues = @{ "Import-Module:Alias"=@() "Import-Module:Function"=’' "Import-Module:Cmdlet"=’' "Import-Module:Variable"=’*' } Get-Module Get-BitsTransfer Get-Module

This example (when used in PowerShell V3) will (from a base PowerShell session) show you what modules are loaded, attempt to run the Get-BitsTransfer command, and then show you what modules are now loaded (should include the BitsTransfer module now).&#160; Since we’ve provided an empty array to the Alias parameter for <a href="http://go.microsoft.com/fwlink/?LinkID=141553" target="_blank">Import-Module</a>, any module that is imported will import any aliases.



### Seems Like It Works… Where’s the Problem?




The problem comes in when you specify that only one of the four parameters (Alias, Function, Cmdlet, and Variable).



You might expect that when you specify one parameter (example Alias), that the other portions of the import (Function, Cmdlet, and Variable) would behave just like if you did not specify any of them. 



Example -



Open a new PowerShell session (V2 or V3) -
This will import BitsTransfer module and all attendant commands and functions.&#160; Note the ExportedCommands in the Get-Module output.



Open a new PowerShell session and try -