Supressing verbose for certain commands when using the verbose paramter?

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of John Mello John Mello 4 years, 1 month ago.

  • Author
    Posts
  • #4134
    Profile photo of John Mello
    John Mello
    Participant

    I generally like to use write-verbose statements as a form of documentation and troubleshooting when working on a script. But some commands like get-mailbox produce more verbose output then I would like and it makes searching for the write-verbose statements I specified difficult. I’ve tried setting the verbose preference manually before and after a get-mailbox command:

    $VerbosePreference = "SilentlyContinue" 
    {CODE}
    $VerbosePreference = "Continue"

     And using the –verbose paramter for get-mailbox (-Verbose:$false)

    $CurrentMailBoxPolicy = (Get-mailbox $CurrentUser -Verbose:$false).ManagedFolderMailboxPolicy

    but I still get around 7 lines of verbose messages (which is less than if I didn’t set either verbose method). Is this just how these cmdlets work or is there something I can do to surpress these messages when I want verbose output from everything else in the script?

     

  • #4138
    Profile photo of Rob Campbell
    Rob Campbell
    Participant

    Try explicitly setting -Verbose:$False on the cmdlets you want to suppress that output for.

  • #4139
    Profile photo of John Mello
    John Mello
    Participant

    I've tried that with get-mailbox (see the example in the inital post) and while it does reduce the amount of verbose messages it still produces around 7 lines worth.

  • #4159
    Profile photo of Rob Campbell
    Rob Campbell
    Participant

    Is that a Exchange EMS environment, or are you importing an Exchange management session and using implicit remoting?  In an implicit remoting session what you're actually getting are proxy functions, and I've noticed that sometimes the common paramters don't work like you expect them to with those proxy functions.

  • #4185
    Profile photo of John Mello
    John Mello
    Participant

    Rob, thanks for the reply. I am importing the session which and your explanation is more than likely what is happening. So I guess the verbose messages I’m getting are actually from the proxying of the cmdlets and not the cmdlets themselves. Which would explain why I can reduce some of the verbose output but not all of it.

You must be logged in to reply to this topic.