I hope to use the Write-Verbose command in scripts and functions. It works as expected in script files (.ps1), but not in module files (.psm1) - the command line is ignored in modules.
Running the following script:
PS> .\scaffold.ps1 -verbose
It produces:
VERBOSE: starting foo path: c:\bar.txt [missing entry here - 'verbose path: c:\bar.txt'] VERBOSE: ending foo
scaffold.ps1:
[cmdletbinding()] param() import-module Common -force write-verbose "starting foo" foo "c:\bar.txt" write-verbose "ending foo"
Common.psm1:
function foo { [cmdletbinding()] Param( [string]$path ) write-host "path: $path" write-verbose "verbose path: $path" }
I did not associate the manifest (.psd1) with the module (.psm1) at this point.
Is there a module specific syntax that I need to use?
** edit **
I need a way to determine if the -verbose flag is -verbose in the -verbose file so that I can transfer it to the .PSM1 file.
scaffold.ps1:
[cmdletbinding()] param() import-module Common -force write-verbose "starting foo" foo "c:\bar.txt" $verbose_flag
craig source share