Exchange Powershell -asjob

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of bishafr bishafr 3 years, 7 months ago.

  • Author
    Posts
  • #10209
    Profile photo of bishafr
    bishafr
    Participant

    trying to get a list of mailboxes and their sizes. Got a script but it takes a very long time to run on the environment of 40000+ users. I'm checking on a method to have each server get their own users and sizes and run it as a job. For some reason the below is not working. Any idea ? (i know about the implicit remoting, interested on how to run Exchange commands as powershell jobs)

    Invoke-Command {
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
    . $env:ExchangeInstallPath\bin\RemoteExchange.ps1
    Connect-ExchangeServer -auto
    get-mailbox} -asjob -computer Servername

  • #10210
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    Because you can't remote into an Exchange machine in that manner. You have to create a PSsession to the Exchange PowerShell URI and import the session. Alternatively install the Exchange admin tools on your admin machine

    To create an session to an Exchange box and import the cmdlets
    $sess = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http:///PowerShell" -Authentication Kerberos -Credential $cred -ErrorAction Stop

    You may be able to leave out the credential

    import the session like this
    Import-PSSession $sess

  • #10213
    Profile photo of bishafr
    bishafr
    Participant

    Ok. I'm interested to run "Get-Mailbox" on multiple servers in parallel (preferably using Powershell jobs).
    Any idea how to do that ?

  • #10214
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    I suspect that the best way to do it is to install the Exchange admin tools on your local machine. Each job will have to install the Exchange snapin (jobs run in a separate PowerShell process) and run the command against the appropriate server

  • #10215
    Profile photo of bishafr
    bishafr
    Participant

    thanks. If you have time to post a quick example would be very helpful.

    All i'm trying to do is have each mailbox server get the mailboxes and their sizes (in parallel) than my computer doing all the work.
    It takes almost 2 days for the script to run from my computer.

You must be logged in to reply to this topic.