Перейти к содержимому

Exchange management shell как запустить

  • автор:

Load Exchange Management Shell in PowerShell ISE

In Exchange Server, we can load Exchange Management Shell module in Windows PowerShell ISE. This way, we can run Exchange cmdlets in PowerShell ISE just like we are used to in Exchange Management Shell. But, is there another way to connect to Exchange Server with PowerShell? This article will teach you how to load Exchange Management Shell snapin in PowerShell ISE.

Table of contents

Information

Microsoft PowerShell ISE stands for Integrated Scripting Environment. Why do we like to use Windows PowerShell ISE if it comes to running scripts or cmdlets?

  • Works more comfortable with the editor
  • Shows you the cmdlets as you type
  • Better interface (GUI)

Error when running Exchange cmdlet in PowerShell ISE

If you run an Exchange cmdlet in PowerShell ISE, you will get an error.

You did get this error because you don’t have Exchange Management Module imported in Windows PowerShell ISE.

Import Exchange Management Module in PowerShell ISE

We want to import the Exchange module in PowerShell ISE on the Exchange Server. We also like to do the same on another server with Exchange Management Tools installed.

To load Exchange snapin in PowerShell ISE, you can run the following cmdlets. Run Get-Mailbox cmdlet to verify that it’s working.

Add Exchange Management snapin Exchange 2010

Run PowerShell ISE as administrator. Add the Microsoft Exchange Management snapin.

Add Exchange Management snapin Exchange 2013/2016/2019

Without Exchange Management Tools installed

We have a management server, and we want to connect to the Exchange Server with PowerShell ISE. If you open it on another server without Exchange Management Tools installed, it will not work.

You get the error because you have to install Exchange Management Tools. After that, run the snapin cmdlet to import Exchange Management Tools.

Connect to Exchange Servers with remote PowerShell

The above Exchange snapin cmdlets will work fine. Is there another way to load the Exchange module in PowerShell? Yes, there is.

In three steps, we can create a remote PowerShell connection to Exchange Server:

  1. Enter credentials
  2. Provide required connection settings
  3. Import Exchange cmdlets

You can connect from Exchange Server itself or another server. For example, a Management Server. The good thing is that you can run this without installing Exchange Management Shell on the remote server. But, some cmdlets will not give you the correct output. For example, the Get-ExchangeCertificate cmdlet will not give you all the properties.

We do recommend to install the Exchange Management Tools on any server to administer Exchange Servers.

Run PowerShell ISE as administrator and run Get-ExecutionPolicy cmdlet to check if it’s correctly set. If it’s not set as RemoteSigned, run the second cmdlet.

1. Enter the credentials

A prompt will show. Fill in the account UPN with admin privileges.

Load Exchange Management Shell in PowerShell ISE Get-Credential

2. Provide required connection settings

Replace EX01-2016.exoip.local to your Exchange server FQDN. The connectionUri is http and not https.

3. Import Exchange cmdlets

Import the Exchange cmdlets in the Windows PowerShell session so you can administer Exchange.

If you get errors when connecting to the PowerShell virtual directory, read Recreate virtual directories in Exchange Server.

Verify it’s working

Run the Get-Mailbox cmdlet and see the results.

If you finished with your work, don’t forget to sign off.

You did connect to Exchange Server from another server or from Exchange server itself. This time with remote PowerShell. Did this load Exchange cmdlets in PowerShell ISE for you?

Conclusion

In this article, you learned how to load Exchange Management Shell in PowerShell ISE. The next time you connect to the Exchange Server, you can connect with remote PowerShell and not load the Exchange snapin. Both ways will work.

It’s best to Install Exchange Management Tools on any server to administer Exchange Servers. After that, import the Exchange snapin in PowerShell ISE. This way, all the Exchange cmdlets are available.

Did you enjoy this article? You may also like Install Exchange Cumulative Update. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

What Others Are Reading

We are upgrading Exchange 2016 CU20 to Exchange 2016 CU21. That’s because updates for Exchange…

How to enable SMTP logging in Exchange Server 2013/2016/2019? We want to check the send…

You want to find the RemoteHostName URL because you have a mailbox migration planned to…

This Post Has 2 Comments

Great post but have issues with some commands that doesn’t work. Is there any way to get all Ex-commandlets to work from ISE on a server that’s not a Ex-server.

For example:
——————————————————————–
PS C:\Windows\system32> Get-MobileDeviceStatistics -Mailbox User
Get-MobileDeviceStatistics : Failed to load assembly; Type=Microsoft.Exchange.Assistants.ItemAssistantContextFactory, Assembly=Microsoft.Exchange.Assistants, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3
856ad364e35
At line:1 char:1
+ Get-MobileDeviceStatistics -Mailbox sle19
+

+ CategoryInfo : InvalidOperation: (LegacyDn: /o=OF…00-000000000000:UserPrincipal) [Get-MobileDeviceStatistics], RegistryAssemblyLoadException
+ FullyQualifiedErrorId : [Server=VM099,RequestId=5c026722-66f1-439d-b941-126c9558031c,TimeStamp=2021-10-20 09:21:37] [FailureCategory=Cmdlet-RegistryAssemblyLoadException] BC79D62E,Microsoft.Exchange.Managem
ent.Tasks.GetMobileDeviceStatistics
—————————————————————————–

Get-Mailbox works fine!

You have two options:

1. Install Exchange Management Tools on the machine
2. Connect to Exchange Servers with remote PowerShell (read the article)

I tried both options on a non-Exchange Server. The “Get-MobileDeviceStatistics -Mailbox -user” command works fine from PowerShell ISE.

Leave a Reply Cancel reply

SpamBull cloud spam filter
Tired of spam and paying high costs? SpamBull cloud spam filter is the solution.

…diary of a EX admin

e14-ps00 Больше PowerShell-а, еще больше! Я бы начал очередную заметку про Exchange Server 2010 с этих слов, впрочем что я уже сделал ��

Для меня PowerShell это то чего мне всегда не хватало в администрировании (думаю и для других тоже) с выходом Exchange Server 2007 в этом убедились все администраторы Exchange Server, рассказывать о прелестях и возможностях PowerShell выходит за рамки моего стиля Pauca Verba (немногословно) да и в интернете вы найдете много профессионально написанных статей на эту тему, а мне дилетанту в этом деле (написании статей, заметок) хочется рассказать о новых приятных “фишках” добавленных в Exchange Server 2010 (далее E14) по части PowerShell (PS)

Пожалуй самое первое что заметит администратор после установки E14 по части PowerShell это то что иконок запуска окна Exchange Management Shell (EMS) стало два! (2) Почему два? (а я вот о чем, Больше PowerShell-а, еще больше!)

Exchange Management Shell
Exchange Management Shell (Local Powershell)

Дело в том что в E14, PowerShell всегда соединяется с сервером через Internet Information Server к каталогу powershell, независимо от того, вы подключаетесь на локальный сервер или на удаленный сервер, тут WinRM является механизмом связи между Shell сессией и сервером E14.

При запуске Exchange Management Shell, происходит подключение к серверу и загрузка доступных cmdled-ов с сервера

Пример подключения EMS к серверу,

e14-ps02 e14-ps01

По умолчанию ярлык запуска EMS содержит параметры

‘C:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1’; Connect-ExchangeServer -auto"

Как нетрудно догадаться что делает -auto, можно создать дубликат ярлыка с параметрам (пример) Connect-ExchangeServer -ServerFQDN e14ex02.corp.postmaster.ge и после запуска работать сразу с удаленным сервером, или в уже запушенном окне переключатся меж серверами (или организациями) командой Connect-ExchangeServer, стоит заметить что данная команда доступна только в RemoteExchange.ps1.

Вы наверно подумаете для чего так намудрили и теперь подключение происходит таким вот образом, а сделано это потому что была ведена Role Based Access Control (RBAC) которая после проверки вашего доступа и делегированных вам прав, позволяет работать в повершелл только с теми cmdled-ами на роли которых вы имеете права, тем самым при запуске вы получаете своё окружение PS.

Также стоит заметить что теперь и Exchange Management Console (EMC) работает по принципу соединения IIS и работа WinRM независимо от того, вы подключаетесь на локальный сервер или на удаленный сервер

Пример подключения EMC к другому серверу или тут про Exchange Online

e14-ps04 e14-ps03

Тут также присутствует RBAC и вы получаете только то что вам дано и не более.

Вы спросите а как же локальная работа на сервере? Для этого мы используем Exchange Management Shell (Local Powershell) который использует уже знакомый нам ‘C:Program FilesMicrosoftExchange ServerV14binExchange.ps1’

Тут все как раньше

e14-ps05

Кстати кто устанавливал Exchange Server 2010 Beta на Windows Server 2008 R2 RC (6.1.7100) наверно встретился с несовместимостью в работе WinRM+PowerShell,

Вот тут то и спасает Exchange Management Shell (Local Powershell) которая работает исправно а вот о EMC и EMS сказать подобное пока нельзя, обещали исправить в следующих версиях E14.

Что еще спросите вы, обратите внимание на окно свойства пользователя, значок PowerShell, теперь все что было изменено можно видеть как это выглядит в PS

alt=»e14-ps07″ width=»192″ height=»170″ /> e14-ps08

Тем самым можно к примеру не зная как это делается с PS всегда научится у того же EMC, далее вам уже нечего не стоит придумать некий ваш скрипт и “за пэйплайнить” несколько скриптов сразу. Очень полезно тем кто незнаком с повершел, можно всегда видеть что происходит на самом деле в PowerShell

Больше PowerShell-а, еще больше!? Ага, вот еще, теперь все проделанные команды можно видит еще и виде лога проделанной работы, все действия проделанные с консоли EMC, логируются в отдельном окне и по завершению работы можно сохранить и заодно посмотреть что же вы 3-мя кликами мыши наделали в повершеле,

e14-ps09 e14-ps10 e14-ps11

Еше PowerShell? А как вам логии всего что происходит в PowerShell так еще и в удобном доступном месте к примеру в почтовом ящике?

Новая фишка Administrator Audit Logging , как она работает? Для начала сконфигурируем ее,
Запускаем наш Exchange Management Shell (Local Powershell) и набираем

e14-ps12

Set-AdminAuditLogConfig -AdminAuditLogEnabled $True
И на заранее созданный почтовый ящик adminauditlog@postmaster.ge направляем наши PowerShell логии
Set-AdminAuditLogConfig -AdminAuditLogMailbox adminauditlog@postmaster.ge
Теперь все проделаные нами действия будут приходить нам на заданыый почтовый яшик,

e14-ps13 e14-ps14

Подробно о команде Set-AdminAuditLogConfig можно как всегда посмотреть командой get-help Set-AdminAuditLogConfig –full, можно сконфигурировать на запись в лог конкретных действий к примеру только set* или set-mailbox* и так далее.

И в заключении я могу сказать одно что в Exchange Server 2010 для начинающих только работать в Exchange Management Shell открываются новые возможности в изучении и познании работы EMS, если раньше мы могли довольствоваться только “выходным содержимым завершившейся команды в визарде” и ее копированием, то теперь можно пожалуй в любом месте сменив любой параметр предварительно увидеть как это выглядит в PowerShell, видеть что происходит на протяжении всей сесии работы, команды повершела, логировать их и получать на маил, ну и теперь скажите что EXCHANGE ROCKS! ��

Install PowerShell for Exchange (Online) on a workstation

Microsoft currently provides version 2 of the PowerShell module for Exchange Online. The installation there works as follows.

First, you must check the standard authentication for Windows Remote Management (WinRM) and, if necessary, configure it from a command prompt with administrative rights. To view the current settings, enter this command:

Displaying current settings for WinRM authentication

By default, the value for Basic should already be true. If this is not the case, you can change it using this:

If this setting is not configured as described, the following error message will appear when you try to connect to Exchange Online:

«The WinRM client cannot process the request. Basic authentication is currently disabled in the client configuration. Change the client configuration and try the request again.»

Installing the module for Exchange Online

To be able to execute scripts, if not already done, you have to loosen the execution policy:

Next, execute the following command from a PowerShell console with administrative privileges.

After this step, close the PowerShell console and then open it again with elevated privileges. Next, I will install the module ExchangeOnlineManagement:

Installing the ExchangeOnlineManagement PowerShell module

…to connect to Office 365 in order to send commands.

Connecting to Exchange Online by using the Connect ExchangeOnline cmdlet

Connecting to Exchange Online by using the Connect ExchangeOnline cmdlet

After you log on, the command will print a small table that shows which cmdlets have changed with the new module.

Installing Exchange Management Shell

On premises, the whole task is a bit more complex because PowerShell for Exchange is part of the management tools. These are on the Exchange installation media.

The first step is to enable some optional features:

Enabling optional features required by the Exchange management tools

Enabling optional features required by the Exchange management tools

In addition, you have to ensure that the correct version of the .NET Framework is installed. After that, you need to add the Microsoft Visual C++ 2012 Redistributable before you can start the actual installation.

The Microsoft Visual C++ 2012 Redistributable is another requirement for the management tools

Now you start the installation of the Exchange management tools with this command:

After executing the setup, you use either the local Exchange PowerShell or the snap-in to administer Exchange.

Setup adds an icon for the Exchange Management Shell to the Start menu

Update

From time to time, you must update both the module for Exchange Online and the management shell for a local Exchange. For Exchange Online, enter the following commands for this purpose:

Subscribe to 4sysops newsletter!

For Exchange on premises, current versions come via cumulative updates every quarter.

Exchange Management Shell — Three methods to connect Exchange Management shell

PowerShell concept is similar to Unix command shell, Powershell allows you to execute all tasks in the Exchange Admin Center, and this is how it works behind the scenes. Pipeline result from one command to another will help you to write scripts and share it in a small text file instead of going step by step with the interface.

Exchange Management Shell can be connected using the following method.

1. Access from Exchange Server.

Remote Desktop or login to Exchange Server locally and then open Exchange Server Management Shell.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *