- Microsoft Graph: A single (PowerShell) API for Microsoft’s cloud services - Tue, Aug 23 2022
- Exchange impersonation: Grant permissions to service accounts - Mon, Aug 8 2022
- Send Microsoft Teams meeting invitations in multiple languages - Thu, Jul 21 2022
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:
winrm get winrm/config/client/auth
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:
winrm set winrm/config/client/auth @{Basic="true"}
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:
Set-ExecutionPolicy RemoteSigned
Next, execute the following command from a PowerShell console with administrative privileges.
Install-Module PowershellGet -Force
After this step, close the PowerShell console and then open it again with elevated privileges. Next, I will install the module ExchangeOnlineManagement:
Install-Module -Name ExchangeOnlineManagement
Installing the ExchangeOnlineManagement PowerShell module
Now you use…
Connect-ExchangeOnline
…to connect to Office 365 in order to send commands.
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:
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementScriptingTools, IIS-ManagementScriptingTools, IIS-IIS6ManagementCompatibility, IIS-LegacySnapIn, IIS-ManagementConsole, IIS-Metabase, IIS-WebServerManagementTools, IIS-WebServerRole
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:
D:\setup /mode:install /role:managementtools /IAcceptExchangeServerLicenseTerms
After executing the setup, you use either the local Exchange PowerShell or the snap-in to administer Exchange.
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!
Update-Module PowershellGet Update-Module -Name ExchangeOnlineManagement
For Exchange on premises, current versions come via cumulative updates every quarter.
fast and beautiful method.
i get trying to run the last command
D:\setup : The term 'D:\setup' is not recognized as the name of a cmdlet, function, script file, or operable program. C
heck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ D:\setup /mode:install /role:managementtools /IAcceptExchangeServerLi …
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\setup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
You need to download the C++ install package and rename it to setup.exe – if you can add it to your D:\ drive or anywhere else that you can reference in the installation
I can't thank you more. Searching microsoft documentation for a simple answer sent me on a loop. Your's was just a KISS.
Installing the Exchange Management Tools forced me to install using the slightly different command D:\setup /mode:install /role:managementtools /IAcceptExchangeServerLicenseTerms_DiagnosticDataON or D:\setup /mode:install /role:managementtools /IAcceptExchangeServerLicenseTerms_DiagnosticDataOFF so the LicenseTerms were accepted.