If you’re in the normal non-Exchange PowerShell or PowerShell ISE and try to run Exchange cmdlet you get the following error:
+ Get-Mailbox <<<<
+ CategoryInfo : ObjectNotFound: (Get-Mailbox:String) , Command
+ FullyQualifiedErrorId : CommandNotFoundException
For Exchange 2010, run:
For Exchange 2007, run:
You could also enter the following to get a list of Powershell Snap-Ins that are registered on the system and that you could use:
Also, when the Exchange Management Shell is started from the startmenu, it actually runs a PowerShell script which does a lot more than the above:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto”
So if you’re missing something when running the simple solution above, try running this ps1 script.
Oh and maybe you’re doing a PowerShell script and need to add the PSSnapIn? Well, if you try to add it several times, you get an annoying errormessage. You could then check if it already has been added or not:
if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null )
If you get tired of adding this SnapIn every time you start Powershell, I suggest you read about_Profiles.