Re: Exchange Management Shell

Forums

Forums, discussions, and Q&A for all products.

Exchange Management Shell

  • rated by 0 users
  • This post has 4 Replies |
  • 0 Followers
  • I am running exchange 2007 on a Windows Server 2008 virtual machine to test out a script to dismount so that eseutil can be used.
    I have thus far been unable to dismount the mailboxdatabase.

    I run this script. What is weird is that the when I run this ps1 script locally it works. When I try to run it in kaseya it runs the exchangedismount.ps1 as evidenced by an updated useraccounts.log file.
    However it just ignores the lines that reference any exchange management shell commands. I also made sure it printed out its user account information using $env:username.

    Thanks for the help.
    James

    Step 1 I have also used use credential, and tried to run the other steps as system.

    IF True
    THEN
    Impersonate User
    Parameter 1 : Administrator
    Parameter 2 : PWD
    Parameter 3 : Domain
    OS Type : 0
    Execute Shell Command
    Parameter 1 : C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe Set-ExecutionPolicy unrestricted
    Parameter 2 : 0
    OS Type : 0


    With Step 3 I have tried three different things.

    Execute File
    Parameter 1 : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter 2 : -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command ". 'C:\temp\exchangedismount.ps1'"
    Parameter 3 : 1
    OS Type : 0

    Execute Shell Command
    Parameter 1 : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command ". 'C:\temp\exchangedismount.ps1'"
    Parameter 3 : 1
    OS Type : 0


    Execute File
    Parameter 1 : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter 2 : -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit -command ". 'C:\temp\exchangedismount.ps1'"
    Parameter 3 : 1
    OS Type : 0





    The Exchange ps1 script is
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin # This is used when I do not call the .psc1 file.
    dismount-database 'Mailbox Database' -Confirm:$false
    dismount-database 'Public Folder Database' -Confirm:$false
    wmic useraccount >> C:\temp\useraccounts #Used only to verify that the powershell script is indeed running.

    Legacy Forum Name: Exchange Management Shell,
    Legacy Posted By Username: jfason
  • If you run it manually does it work?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jasonb
  • Check out this thread I participated in a few months ago.



    Running Scripts on Exchange 2007

    http://community.kaseya.com/xsp/f/28/t/5978.aspx



    I was trying to use PowerShell with Exchange Server 2007. Commands woruld work from a comman line, but not from a Kaseya script. In summary, the problem was that the K Agent was using 32-bit system, and Exchange Server 2007 powersheel needs the 64-bit system.



    Details are in the thread. But in summary, the command that finnaly worked was:



    %windir%\Sysnative\cmd.exe /c PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" "C:\Mailbox.ps1"





    Hope this helps.



    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Thanks that worked for me!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: chris021
  • Worked for me too - thanks!!!!

    I am using this command to check Exchange mailbox sizes:

    Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Page 1 of 1 (5 items)