ScriptsToProcess in Manifest doesn't produce Verbose logging

Welcome Forums General PowerShell Q&A ScriptsToProcess in Manifest doesn't produce Verbose logging

This topic contains 2 replies, has 2 voices, and was last updated by

1 year ago.

  • Author
  • #94509

    Points: 45
    Rank: Member


    My verbose logging does not output for a script that gets called when my module gets imported. The module manifest contains a script to process for when the module is imported. Now when I run the cmdlet to import the module with the verbose parameter set, no verbose logging outputs from the script.

    # within Module Manifest
    # Script files (.ps1) that are run in the caller's environment prior to importing this module.
    ScriptsToProcess = '.\ScriptToProces.ps1'
    # run the following in PowerShell
    Import-Module MyModule -Verbose

    I expect the verbose logging I set up in my ".\ScriptToProcess.ps1" script to output, but it doesn't. I am sure this has something do with scope, but I have tried a few things and have been unsuccessful.

    I thought as a solution to be able to verify if the -Verbose parameter was used with Import-Module, then I can set my $VerboseParameter from within my script. I have not figured it out.

    Any suggestions?

    – Michael

  • #94651

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    I'm fairly sure that's by design. However, it'd make sense to log it as an Issue on the PowerShell GitHub repo if you think the behavior should be different.

    • #94656

      Points: 45
      Rank: Member

      Hey Don,

      I found a (call it if you'd like) "work-around" for this scenario.

      I added a parameter to my 'ScriptToProcess.ps1' called [bool] $Verbosity and add an argument to the import module like such: "Import-Module MyModule -ArgumentList $true". That arg is accepted by 'ScriptsToProcess' and I have additional logic to set the $VerbosePreference to "Continue" if the $true arg is passed.

      Ill definitely add it to the PowerShell Github to see what the PowerShell team says.


The topic ‘ScriptsToProcess in Manifest doesn't produce Verbose logging’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort