Exchange commands from a Linux Terminal
Hi all,
This is my first post in 7 months and the first one in English here too, expecting an wide audience :) A few days ago, a Premier Support customer asked me, during an onsite work, for some way to execute Exchange based commands through Linux Terminal or some applet which emulates the Linux terminal. At the first moment, it could looks challenging. Run Exchange cmdlets on a Linux based OS??? However, it is much more simple than you can think at the first moment.
You know that is absolutely ok run Exchange cmdlets in any Windows command prompt, don't you? Starting with this, you just need to give to the Linux the ability to remote connect to its prompt, and the answer for that need is the Telnet Server. You need to install the telnet server feature in the server that is able to load the Exchange shell console, meaning a Windows computer with the Exchange Management Tools installed.
After telnet feature installation, you just need to connect from the Linux terminal or applet
telnet <telnet server ip address>
Now, in order to be able to execute the cmdlets, you need to load exchange shell console file. Let's get the mailbox list:
powershell.exe -psconsolefile "c:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command "get-mailbox"
And using 2 or 3 commands in the same line, something like disconnects a mailbox and reconnects to another user:
powershell.exe -psconsolefile "c:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command "$mailbox=get-mailbox;disable-mailbox user1 -confirm:$false;clean-mailboxdatabase $mailbox.Database.ToString();connect-mailbox user1 -database $mailbox.Database.ToString() -user "new user""
Note that all you need is split the lines using ";". You also can run some script placed on the Exchange server, which helps when we are talking about a Linux server that runs some application responsible for Identity Management:
powershell.exe -psconsolefile "c:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -command "Script.ps1"
I totally agree that kind of procedure is so much oriented for very specific scenarios...However I really like to think that is always good to know this such thing works... We don't know what will be the customer needs in the end of the day...
;)
Comments
- Anonymous
January 07, 2016
The comment has been removed