Question About Import-Module

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Tee Tee 2 months, 3 weeks ago.

  • Author
    Posts
  • #53934
    Profile photo of Tee
    Tee
    Participant

    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
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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
      Profile photo of Tee
      Tee
      Participant

      Thanks Don. That's what I thought.

You must be logged in to reply to this topic.