Exchange 2019 / 2016 Manage Remotely via PowerShell

KB ID 0001465

Problem

Since Exchange 2013 we have been able to manage Exchange remotely through the Exchange Admin Center, but what if you want to use the Exchange Management Shell remotely?

Install Exchange Management Tools

This is not just the Management Shell, this will also install the Toolbox and additional help.

There are few prerequisites, but to install from a normal PowerShell prompt;

[box]

Enable-WindowsOptionalFeature -Online -FeatureName IIS-ManagementScriptingTools,IIS-ManagementScriptingTools,IIS-IIS6ManagementCompatibility,IIS-LegacySnapIn,IIS-ManagementConsole,IIS-Metabase,IIS-WebServerManagementTools,IIS-WebServerRole

./Setup.exe /Role:ManagementTools /IAcceptExchangeServerLicenseTerms

[/box]

Once Installed, You can launch the Shell itself, or you can add the Exchange PowerShell commandlets to a normal Powershell session, with the following command;

[box]

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

[/box]

For older versions of Exchange, the commands are slightly different;

  • Exchange 2010: Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010;
  • Exchange 2007 :Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin;

Connect to Exchange Remotely (via PowerShell)

It’s a Windows server after all, so you can bring up a remote session, first give it an account with some Exchange administrative privileges;

[box]

$UserCredential = Get-Credential

[/box]

Then connect the the Exchange Server;

[box]

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://Server-Name/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession $Session -DisableNameChecking

[/box]

Note: As above, don’t forget to disconnect the session the you have finished.

[box]

Remove-PSSession $Session

[/box]

Related Articles, References, Credits, or External Links

NA

Lync 2010 – ‘The address book is preparing to synchronize. Search results might not be current’

KB ID 0000529 

Problem

Saw this on a brand new installation on my test bench, I left it overnight and the problem still did not resolve.

Solution

1. On the Lync 2010 Server launch the “Lync Server Management Shell” and execute the following command:

[box]Update-CsAddressBook[/box]

2. Go and have a cup of coffee, then come back and check in the event logs, you should see, Event 21005 (Sync has Started), 21010 (Sync has completed), 21056 (Details of the sync), and 21004 (Time of next sync).

3. If that does not rectify the problem you can (On a PC showing this error) Start > Run Regedit {enter} > Navigate to:

[box]HKLMSoftwarePoliciesMicrosoftCommunicator[/box]

Create or edit a the DWORD GalDownloadInitialDelay and set its value to 0

4. Close the Lync Client and delete the GalContacts.db and GalContacts.db.idx files form that PC. you will find those file in the following locations

Windows XP: %userprofile%Local SettingsApplication DataMicrosoftCommunicatorsip_<the_username@the_domain>

Windows Vista/7: %userprofile%AppDataLocalMicrosoftCommunicatorsip_<the_username@the_domain>

4. Restart Lync.

Related Articles, References, Credits, or External Links

Install and Configure Microsoft Lync 2010

Exchange 2013 – ‘The WinRM Shell client cannot process the request’

KB ID 0000855

Problem

After building a new Exchange 2013 Server on my test network and changing the Certificate over, I ran a few updates and rebooted. Post reboot I was greeted with this,

VERBOSE: Connecting to PNL-EX2013.petenetlive.net.
New-PSSession : [pnl-ex2013.petenetlive.net] Processing data from remote server pnl-ex2013.petenetlive.net failed with the following error message: The WinRM Shell client cannot process the request. The shell handle passed to the WSMan Shell function is not valid. The shell handle is valid only when WSManCreateShell function completes successfully.
Change the request including a valid shell handle and try again. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ New-PSSession -ConnectionURI “$connectionUri” -ConfigurationName Microsoft.Excha …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme….RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
gTransportException
+ FullyQualifiedErrorId : -2144108212,PSSessionOpenFailed
Failed to connect to an Exchange server in the current site.
Enter the server FQDN where you want to connect.:

Solution

Everything was working fine before I changed the certificates, and all the management runs out of IIS so I headed there first. I found when I checked the ‘bindings’ for the ‘Exchange Back End’ site that HTTPS did not have a certificate selected.

After I selected the correct certificate, the Command Shell opened fine.

Related Articles, References, Credits, or External Links

NA

 

Exchange 2010 – Delete / Remove all Disconnected Mailboxes

KB ID 0000470 

Problem

In older versions of Exchange, we just had to “Purge” disconnected mailboxes, now we don’t have that option.

Solution

WARNING this will remove ALL disconnected mailboxes, make sure you actually want to do this before proceeding.

Launch > Exchange Management Shell.

Issue the following commands;

[box] $mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database [/box]

Then;

[box] $mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false } [/box]

2. If you have the Exchange Management console open (as above), you may need to refresh, before they disappear.

Related Articles, References, Credits, or External Links

NA