Question About Import-Module

This topic contains 2 replies, has 2 voices, and was last updated by  Tee 1 year, 10 months ago.

  • Author
  • #53934


    I was wondering if I could get some clarification about something. I have a bat file that calls a powershell script using the ExecutionPolicy of bypass. Anyhow, in my script I'm doing a import-module on PSExcel.psd1. As a developer, I like to clean up after myself once I'm finished with my processing. I know when you use Import-Module that module is available only during that session so I'm assuming calling Import-module for each call to my script is okay. However, I'm wondering if I should do a remove-module at the end of my script just as a good practice. Any input on this? Should I not worry about calling remove-module or should I?

  • #53945

    Don Jones

    No need at all. Even if you import the same module over and over, all you'll get is a warning saying it was already done, and PowerShell manages its scopes quite well.

    • #53957


      Thanks Don. That's what I thought.

You must be logged in to reply to this topic.