<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Managing Exchange online Office365 and On premises with the Exchange Management Shell

Published on
10,953 Points
4,853 Views
1 Endorsement
Last Modified:
Approved
It has been a great concern for Administrators to manage Exchange online and Exchange On Premises. A Windows PowerShell technology, Exchange Management Shell facilitates the task. The shell allows you to manage every important aspect of Exchange, including enabling email accounts, configuring database properties, creating send and receive connectors, etc. Below are some important tips to use PowerShell for managing Exchange Online in Office365.


Connecting to Exchange Online

You can easily connect to Exchange Online using Remote Powershell. To do so, follow the given steps:
Launch Windows Powershell and execute the following:
$UserCredential = Get-Credential
 
Provide the username and password of the account through which you need to connect to Exchange Online in the Windows Powershell Credential Request dialog. Click 'OK'.

If you specify incorrect username or password, you may receive the following message:

Connecting to remote server failed with the following error message : Access is denied.

Run the given command to create a new connection to the Exchange Client Access Server.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ps.outlook.com/powershell/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Execute the following to import all commands in this session:

Import-PSSession $Session

Here, you need to run Import-PSSession cmdlet; but before running it, check whether you have permission to run the scripts. If the following message displays when you run the script, you need to enable the execution of scripts.

File skipped because of the following validation except
ion: File ~\Temp\tmp_ab665a-4654-3684-3d32b_cuwqdhef.gqv\tmp_7465acc6-7657-85bb54d7f55g_fdfgtrsd.gqv.format.ps1xml cannot be loaded because the execution of scripts is disabled on this system.


For enabling the scripts execution, you need to run the Set-ExecutionPolicy Unrestricted cmdlet. Moreover, the parameter AllowRedirection uses different URI and allows redirection to an appropriate Exchange server.


Using '-Prefix' for connecting to Exchange Online and Exchange On Premises Simultaneously

To connect to Client Access Server in Exchange On Premises using Remote PowerShell, you launch Exchange Management Shell. It can be seen when you run Get-PSSession after launching the Exchange Management Shell. When you try creating a new persistent connection to Exchange Online, you may get the following warning message:

“WARNING: Proxy creation has been skipped for the following command: …., because it would shadow an existing local command. Use the AllowClobber parameter if you want to shadow existing local commands.”

As directed by the message, if AllowClobber parameter is used, you wil end up replacing the existing commands. To resolve the problem, you can use the parameter Prefix. This adds a prefix to the names of imported commands, which helps prevent shadowing the existing commands. Run the command as follows:

'Import-PSSession $Session –Prefix AXD'

Here, the prefix is 'AXD'.

Closing PSSessions

Run the cmdlet 'Remove-PSSession'. It will close all the PowerShell sessions (as suggested by name), stop all the commands running in PowerShell sessions, end the sessions, and free all the resources used by PSSession. On the other hand, if the session is connected with a remote system, then also you can use the Remove-PSSession cmdlet to close the connection between remote and local systems. It is necessary to follow the described process because if you do not disconnect from server-side session and close the PowerShell window, you will leave the connection open for 15 minutes and you are allowed to have only 3 connections to server-side session at a time for each account.

Mentioned are the important and useful tips that you can consider. Other than this, you may also use Windows PowerShell profiles.
1
0 Comments

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month