Import module in profile without prompt

This topic contains 4 replies, has 2 voices, and was last updated by  Jonathon Olson 4 years, 7 months ago.

  • Author
  • #11685

    Jonathon Olson

    Is there any way to use import-module without a prompt to load modules from a profile at PowerShell start? I don't see a -quiet switch for the cmdlet.

  • #11686

    Don Jones

    It's probably your execution policy. Import-Module doesn't generate a prompt per se. But the right combination of module and execution policy can certainly generate prompts.

    What's (a) the prompt you're seeing and (b) your execution policy?

  • #11687

    Jonathon Olson

    Ok. It is probably the particular module I am trying to load. () The line in my profile is:

    import-module dnsshell

    Security Warning
    Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your
    computer. Do you want to run C:\Users\Jolson\Documents\WindowsPowerShell\Modules\dnsshell\DnsShell.Format.ps1xml?
    [D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"):

    PS C:\Users\Jolson> Get-ExecutionPolicy

  • #11688

    Don Jones

    The module is a script module, which puts it under control of your execution policy. Even under "Unrestricted," the shell prompts (by default) for scripts coming from a remote location, or scripts you downloaded from the Internet (Outlook and IE both flip a bit in the file header). Option 1, flip the bit so the file doesn't look like it came from the Internet (see

    Alternately, you can use the Bypass execution policy (see

    See for background information. The behavior is also documented in the Set-ExecutionPolicy cmdlet's help, I believe.

    • #11690

      Jonathon Olson

      Thanks, removing the Zone.Identifier information allows it to load. I used the Sysinternals tool, but wondering if it could have been done in Powershell came across this Stack Overflow post:
      There's an unblock-file cmdlet in PowerShell v3, but overwriting the stream info with cmd /c "echo.>test.exe:Zone.Identifier" would be a way to do this without leaving the shell.

You must be logged in to reply to this topic.