How do I enable Verbose mode for the cmdlets within the function?
I added [CmdletBinding()] but that will only print write-verbose to screen but not enabling Verbose for New-ADUser or whatever Cmdlet I called within the script.
How do I enable Verbose mode for the cmdlets within the function?
I added [CmdletBinding()] but that will only print write-verbose to screen but not enabling Verbose for New-ADUser or whatever Cmdlet I called within the script.
Not sure I completely understand your question.
However, You should have a look at “Get-help about_functions_advanced”: With Advanced functions you can take advantage of the common -verbose parameter. Simply output your verbose output this way:
Write-Verbose "Text of debug"
when the shell’s $VerbosePreference variable isn’t set to “SilentlyContinue” (“Continue” will enable the output), you’ll see your verbose output.
Alternatively you can write your own verbose output for your script and use Write-Verbose for whichever line you require.