Don’t you hate it when you launch Exchange 2010’s Management Shell and you are greeted with a lovely message like this:
Microsoft.PowerShell.Commands.ExportPSSessionCommand, Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 : Unable to find type [Microsoft.PowerShell.Commands.ExportPSSessionCommand, Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]: make sure that the assembly containing this type is loaded.
I’ve got one script and a shortcut change that fixes this issue. Create a simple PowerShell script on your local machine and save it as “Cleanup-OldRemoting.ps1” in whatever folder you like. Here is the content of that script:
#Cleanup-OldRemoting.ps1
$Path = Join-Path -Path $env:USERPROFILE -ChildPath “AppDataRoamingMicrosoftExchangeRemotePowerShell”
Get-ChildItem -Path $Path | Where-Object { $_.PsIsContainer -and $_.BaseName -like ( “*” + $env:USERDNSDOMAIN + “*” ) } | Remove-Item -Recurse -Force -Confirm:$false
Now, let’s create a new shortcut on the desktop (or wherever you like). You should just point the shortcut to C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -version 3.0 -noexit -command “. ‘D:ScriptsExchangeManagementCleanup-OldRemoting.ps1’;. ‘C:Program FilesMicrosoftExchange ServerV14binRemoteExchange.ps1’; Connect-ExchangeServer -auto”, click next and save it as “Exchange Management Shell (PoSH 3)” to differentiate is from the pre-existing shortcuts. Make sure that you change the path to the Cleanup-OldRemoting.ps1 to wherever you saved yours.
Let’s get crazy and open up the properties and change the shortcut. Browse to %SystemRoot%Installer{4934D1EA-BE46-48B1-8847-F1AF20E892C1}PowerShell.exe for the Exchange Management Shell icon.
Now, you can run something like this next script and actually get a response to the Grid View (if you have PowerShell ISE installed).
Get-MailboxDatabase | Where-Object { $_.ReplicationType -eq “Remote” } | Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, Database, ArchiveDatabase | Out-GridView -Title “Replicated Mailbox Summary”
I’ve got a huge script that I’m working on regarding Exchange Web Services, so keep an eye out for that.
Ramble on!
I solved this problem a lot easier. I changed the shortcut:
from:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto”
to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 3.0 -noexit -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto”