locked
Powershell Imports Module but I can't run the commands from the module RRS feed

  • Question

  • Hi,

    recently I wrote a PS script to do the maintenance from some servers. My script works just fine in Windows Server 2012/2012R2 but in 2008/2008RE I think I have some kind of bug. When I import the Windows Update Module for Powershell it works fine when I close the PS and open it again and make a command from the module I imported it says that he doesn't know the command and when I try to import the same Module again it says that he already knows the library.

    Wednesday, January 24, 2018 3:24 PM

All replies

  • Not enough information to understand your issue.

    What module and how are you importing it?

    What is the exact command and error message.


    \_(ツ)_/

    Wednesday, January 24, 2018 4:41 PM
  • hi LightZumo,

    The module you are importing is specific to that console window only.

    Whenever you open a new console window you need to import the module again. This is because, on 2008 server we have Powershell version 2 and it doesn't have module autoloading feature.

    In server 2012, the modules placed at specific location, autoloads automatically whenever any cmdlets related to that module is called.

    So, the only option with you is to add a single line in your script to import the required module.

    Import-module "Module Name"

    • Edited by asharma5 Thursday, January 25, 2018 4:21 AM
    Thursday, January 25, 2018 4:19 AM