PowerShell: Disable Automatic Loading of Modules in PowerShell 3.0

 

One of the new features in PowerShell 3.0 is the Auto Loading of Modules.

This feature is great for discovering commands, but can be really annoing when trying to test if your script works as it is supposed to.

Luckily we can change the settings using an automatic variable.

$PSModuleAutoloadingPreference

Here is the info from the help:

$PSModuleAutoloadingPreference
——————————
      Enables and disables automatic importing of modules in the session.
      “All” is the default. Regardless of the value of this variable, you
      can use the Import-Module cmdlet to import a module.

      Valid values are:

        All    Modules are imported automatically on first-use. To import a
               module, get (Get-Command) or use any command in the module.

        ModuleQualified
               Modules are imported automatically only when a user uses the
               module-qualified name of a command in the module. For example,
               if the user types “MyModule\MyCommand”, Windows PowerShell
               imports the MyModule module.

        None   Automatic importing of modules is disabled in the session. To
               import a module, use the Import-Module cmdlet.      

      For more information about automatic importing of modules, see about_Modules
      (http://go.microsoft.com/fwlink/?LinkID=144311).

For more information, see about_Modules, about_Preference_Variables,

By | 2013-06-06T11:12:10+00:00 June 6th, 2013|Powershell, Scripting & Development|0 Comments

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at http://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

Leave A Comment