Monitoring Exchangeserver 2007 using powershell


  • Hello All,

    I have a problem with Exchange server 2007. I was trying to execute the following query get-mailbox | FL. This query was working when I tried it in the Exchange server's power shell console after executing following snapin Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin.

    But I need it to be executed from a remote machine, so I have executed it from same powershell console , as follows...

    $server='';$pwd= convertto-securestring '123' -asplaintext -force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'exchangeserver\Administrator',$pwd; invoke-command -computername $server -credential $cred -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin get-mailbox | FL}

    But, this query fails with the following error...

    The term 'Get-mailboxdatabase' is not recognised as the name of a cmdlet, function, script file or operable program.
    Check the spelling of the name, or if a path was included, verify that the path is corerct and try again.

    I tried the above query from a remote machine, then I got the following error

    A positional parameter cannot be found that accepts argument 'get-mailbox'.

               +CategoryInfo  :InvalidArgument:  {:} [Add-PSSnapin], ParameterBIndingException
               +FullyQualifiedErrorId: PositionalParameterNotFound,Microsoft.Powershell.Commands.AddPSSnapinCommand

    Can someone help me on this?

    • 편집됨 Annie Joseph 2012년 3월 12일 월요일 오전 11:58
    2012년 3월 12일 월요일 오전 11:56

모든 응답

  • Try adding a semi-colon (";") between Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin and get-mailbox | FL

    {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin; get-mailbox | FL}

    However, the easiest method is to install the tools locally....
    You can get the 64 bit tools off the DVD, or the 32 bit tools from


    My Blog:
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    • 편집됨 Just Karl 2012년 3월 12일 월요일 오후 8:06
    2012년 3월 12일 월요일 오후 8:05
  • Hi,

    Thanks for your replay. I tried the way you said, in both local system and in remote system.

    $server='';$pwd= convertto-securestring '123' -asplaintext -force;$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist 'exchangeserver\Administrator',$pwd; invoke-command -computername $server -credential $cred -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin; get-mailbox | FL}

    but I got the following error in both the cases:

      Active Directory server exchangeserver.*.local is not available. Error message: The supplied credential is invalid

      +CategoryInfo            : NotSpecified:{0:Int32}[Get-Mailbox], ADOperationException

      +FullyQualifiedErrorId : A2B6F75B,Microsoft.Exchange.Management.RecipientTasks.GetMailbox

      Can someone help me on this?

    • 편집됨 Annie Joseph 2012년 3월 15일 목요일 오전 5:02
    2012년 3월 13일 화요일 오전 4:45