Connect to Exchange Online PowerShell. If you want to use multi-factor authentication (MFA) to connect to Exchange Online PowerShell, you need to download and use the Exchange Online Remote PowerShell Module. And Windows Management Framework 5.1. Windows PowerShell needs to be configured to run scripts, and by default, it isn.
I am struggling getting Exchange mManagement Shell commands to run in my C# code. Here' the problem.
I have access to a test Exchange Server running Exchange 2010.
I have run my Exchange Mgmt Shell commands directly on the server inside the Exchange Mgmt Shell Simple Example: get-mailbox
I created a console app to run my PS commands
I placed the exe file on the Exchange Server and tried to run it
I get an error on the PSSnapInInfo info = rsConfig.AddPSSnapIn line of code:
There is another post with this exact same issue but no real answer so I am starting this one.
The problem is simple. I can't add the snapin called 'Microsoft.Exchange.Management.PowerShell.Admin'. All the documentation I read on the net says this is the command that will work. In fact I found this post, http://msdn.microsoft.com/en-us/library/bb332449(EXCHG.80).aspx that is very straight forward and seems very simple. Did 'Microsoft.Exchange.Management.PowerShell.Admin' go away in Exchange 2010? Is there another snapin I should be referencing? This should ber really simple but I can't get past this error.
BTW, the error I get is: 'No snap-ins have been registered for Windows PowerShell version 2.'
Any help would be appreciated.
RJ.RJ.1 Answer
Assuming the server is 64-bit, it might be related to how the snap-in was registered. For example, if you're running the x86 version of PowerShell it runs in WOW. Therefore, when you run InstallUtil to register the snap-in it gets registered specifically for x86, which in turn is not available to x64. Assuming this, if your C# application was compiled specifically for the x86 platform I would bet that it would work. This is one solution, but not always acceptable.
Ensure that you're running the correct version of PowerShell (x86/x64) and rerun the snap-in registration with the correct version of InstallUtil. For x64, you'll need to run the InstallUtil that lives under the .NET Framework64 directory.
One way to check you're in the correct version of PowerShell is to examine the environment variable, env:PROCESSOR_ARCHITECTURE in your shell.
x64:
x86:
Scott SaadMicrosoft Exchange Management Shell Do…
Scott SaadExchange Management Shell 2013
Not the answer you're looking for? Browse other questions tagged c#.netasp.netpowershellexchange-server or ask your own question.
Related articles:
Exchange Management Shell 32 Bit Download
Exchange Management Shell Download 2010
Keep this Cheat Sheet of mailbox-related Microsoft Exchange Server 2007 commands handy when you open the Exchange Management Shell to make your mailbox administration tasks as easy as can be.
Command | Description |
---|---|
Get-MailboxCalendarSettings | Displays the calendar processing settings for the specified mailbox. |
Set-MailboxCalendarSettings | Enables calendar processing for the specified mailbox. You can configure parameters for automatic resource booking or Calendar Attendant processing. |
Get-EmailAddressPolicy | Displays the e-mail address policies for the specified mailbox. If you don’t specify the mailbox name, you see a list of available policies (such as Default Policy). |
New-EmailAddressPolicy | Defines a new e-mail address policy for the specified mailbox. If you don’t provide a mailbox name, Exchange Server creates the new policy but doesn’t associate it with a mailbox. |
Remove-EmailAddressPolicy | Deletes the e-mail address policy associated with a particular mailbox. |
Set-EmailAddressPolicy | Associates an e-mail address policy with a particular mailbox. |
Update-EmailAddressPolicy | Applies an e-mail address policy to a group of recipients. |
Get-Mailbox | Displays a particular mailbox and shows its configuration settings. Using this cmdlet without specifying the mailbox displays a list of all mailboxes on the system. |
Get-MailboxStatistics | Displays the statistics (mailbox size, number of messages, last access date, and other information) for a particular mailbox. |
Get-MailboxFolderStatistics | Displays the statistics (the number and size of items in the folder, folder name and ID, and other information) for a particular mailbox folder. |
Connect-Mailbox | Associates a disconnected mailbox with a particular user account. This cmdlet undoes the action of the Disable-Mailbox cmdlet. |
Disable-Mailbox | Removes access to a particular user’s mailbox from Active Directory. The user account remains accessible, but the mailbox is no longer available for use. |
Move-Mailbox | Changes the physical location of the specified mailbox. |
New-Mailbox | Creates a new mailbox. |
Remove-Mailbox | Deletes both the specified mailbox and the user account associated with that mailbox. This is a one-way configuration change, so make sure you save any user information you need before using this cmdlet. |
Restore-Mailbox | Obtains the content of a mailbox from a recovery database and makes it available for use. |