Suppressing verbose output for Import-PSSession cmdlet

Welcome Forums General PowerShell Q&A Suppressing verbose output for Import-PSSession cmdlet

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

 
Participant
2 years, 11 months ago.

  • Author
    Posts
  • #32114

    Participant
    Points: 0
    Rank: Member

    I wrote a function which creates AD users and their mailboxes in bulk by using input .csv file. In order to run Enable-Mailbox cmdlet I put these lines in BEGIN script block:

    $exchsession = New-PSSession -ConfigurationName microsoft.exchange `
    -ConnectionUri http://exch.test.com/powershell
    Import-PSSession $exchsession -DisableNameChecking | Out-Null

    I have many Write-Verbose cmdlets in my function but having called function with -Verbose parameter there are VERBOSE: Importing function '.....' for each imported function. How to suppress these VERBOSE lines only for Import-PSSession cmdlet?

  • #32116

    Participant
    Points: 0
    Rank: Member

    Hi,

    I had this issue too, you can run it with -verbose:$false, so the entire command is:

    Import-PSSession $exchsession -DisableNameChecking -verbose:$false | Out-Null

  • #32122

    Participant
    Points: 0
    Rank: Member

    I tried this but to no avail.

  • #32138

    Participant
    Points: 0
    Rank: Member

The topic ‘Suppressing verbose output for Import-PSSession cmdlet’ is closed to new replies.