Ayehu Eyeshare: Executing Exchange 2010 Powershell Commands From Eyeshare

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

December 2013

Ayehu eyeShare

Executing Exchange 2010 PowerShell


Commands From eyeShare

December 2013

1
www.ayehu.com
December 2013

Contents
Ayehu eyeShare ............................................................................................................................... 1

Executing Exchange 2010 PowerShell Commands From eyeShare................................................. 1

December 2013 ............................................................................................................................... 1

Preparations .................................................................................................................................... 3

DOMAIN MEMBERSHIP .................................................................................................................................... 3


EYESHARE EXECUTOR ....................................................................................................................................... 3
EXCHANGE MANAGEMENT TOOLS ...................................................................................................................... 3
POWERSHELL EXECUTION POLICY ....................................................................................................................... 4
Running an Exchange PowerShell command .................................................................................. 5

CREATE THE COMMAND OBJECT ......................................................................................................................... 5


ADD COMMAND ARGUMENTS ........................................................................................................................... 5
Top 10 Exchange PowerShell Commands ....................................................................................... 6

1. GET-MAILBOX ....................................................................................................................................... 6
2. NEW-MAILBOX ...................................................................................................................................... 6
3. GET-MAILBOXSTATISTICS ......................................................................................................................... 6
4. SET-MAILBOX ........................................................................................................................................ 6
5. GET-MAILBOXPERMISSION ...................................................................................................................... 6
6. GET-MAILBOXSERVER ............................................................................................................................. 6
7. GET-MAILBOXDATABASE ......................................................................................................................... 6
8. DISABLE-MAILBOX.................................................................................................................................. 6
9. ENABLE-MAILBOX .................................................................................................................................. 6
10. ADD-DISTRIBUTIONGROUPMEMBER ..................................................................................................... 6
Example ........................................................................................................................................... 7

Troubleshooting .............................................................................................................................. 8

2
www.ayehu.com
December 2013

Preparations
Domain Membership
The eyeShare server must be a member of the domain to be able to run remote shell exchange
commands. If the eyeShare server is not a domain member, add it to the domain.

eyeShare Executor
The eyeShare executor service must run with the permissions of a domain user that has
Exchange privileges.

Exchange Management Tools


Install the exchange management tools on the eyeShare server. Follow these instructions to
complete the installation:

1. Login to the eyeShare server with a domain admin user.

2. Execute the Exchange 2010 setup.

3. Select the custom setup option, and check the Management Tools component only.

4. Click Next until the installation is completed.

3
www.ayehu.com
December 2013

PowerShell Execution Policy


To allow any PowerShell script to run from the eyeShare server, the PowerShell Execution Policy
should be set to RemoteSigned. Follow the example in this screenshot to set the Execution
Policy:

4
www.ayehu.com
December 2013

Running an Exchange PowerShell command


Create the Command object
1. From the eyeShare Studio  Repository  Commands, create a new command object.

2. Insert the following command in the Command field:

For a 64-bit server: @%windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe

For a 32-bit server: Powershell.exe

Add Command Arguments


Each Exchange PowerShell command must begin with the following arguments, and be followed
with the specific command:

-inputformat none -command ". 'c:\Program Files\Microsoft\Exchange


Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer
ServerName.DomainName.com -ExecutionPolicy Bypass; <Command>

5
www.ayehu.com
December 2013

Top 10 Exchange PowerShell Commands


Remember, each command must begin with the arguments mentioned in the above section.

Make sure to replace each parameter inside <> with its correct value.

1. Get-Mailbox
get-Mailbox "<User Logon Name>" -erroraction 'silentlycontinue'| Format-List -Property Name,
Alias, Email*

2. New-Mailbox
$password = ConvertTo-SecureString "<Password>" -AsPlainText -Force; New-Mailbox -
UserPrincipalName <User Logon Name>@<Domain Name> -Alias <User Name> -Database
<Mailbox Database Name> -Name <User Name> -OrganizationalUnit <OU Name> -Password
$password -FirstName <User First Name> -LastName <User Last Name> -DisplayName <User
Display Name> -ResetPasswordOnNextLogon $true

3. Get-Mailboxstatistics
get-mailboxstatistics -Identity <UserLogonName> -erroraction 'silentlycontinue' | where
{$_.ObjectClass –eq “Mailbox”} | format-list StorageLimitStatus,TotalItemSize,Itemcount;"

4. Set-Mailbox
set-mailbox <Domain Name>\<User Logon Name> -ProhibitSendReceiveQuota 1GB

5. Get-MailboxPermission
Get-MailboxPermission -Identity <User Logon Name>@<Domain Name>

6. Get-MailboxServer
Get-MailboxServer –Identity <Server Name>

7. Get-MailboxDatabase
Get-MailboxDatabase -Server <Server Name>

8. Disable-Mailbox
Disable-Mailbox <User Logon Name>@<Domain Name> -Confirm:$False

9. Enable-Mailbox
Enable-Mailbox <User Logon Name>@<Domain Name>

10. Add-DistributionGroupMember
Add-DistributionGroupMember -Identity "<DL Name>" -Member "<User Logon
Name>@<Domain Name>"

6
www.ayehu.com
December 2013

Example
The following command and arguments return mailbox statistics of a user named “Nick”:

@%windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -inputformat none -command


". 'c:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-
ExchangeServer xch.rnddc.com -ExecutionPolicy Bypass; get-mailboxstatistics -Identity Nick -
erroraction 'silentlycontinue' | where {$_.ObjectClass –eq “Mailbox”} | format-list
StorageLimitStatus,TotalItemSize,Itemcount;"

Result:

7
www.ayehu.com
December 2013

Troubleshooting
1. Error “The term 'c:\Program Files\Microsoft\Exchange
Server\V14\bin\RemoteExchange.ps1' is not recognized 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 correct and try again.” means that the exchange
management tools were not installed properly. Verify that the installation was
successful and that the path c:\Program Files\Microsoft\Exchange
Server\V14\bin\RemoteExchange.ps1 exists on the eyeShare server.

2. In case you get the error “The term '<command>' is not recognized as the name of a
cmdlet….” make sure that the Exchange Snap-ins are installed by running this command
from the command line:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Get-PSsnapin

In case there isn’t any Exchange Snap-ins installed, run this command:

add-PSSnapIn *ex*

8
www.ayehu.com

You might also like