How to connect to Exchange Online via PowerShell using a Mac

Is the first time using a Mac and I was wondering if I’m able to connect to exchange online using a computer with another operating system different as windows.

The first attempt was with Powershell Core and I downloaded the version 6.2.1 from https://github.com/PowerShell/PowerShell/releases/tag/v6.2.1 to get the package to install on my Mac.

Once I got the package I started with the installation

Powershell has been installed successfully, then its moment to try the connection to exchange online

As you can see in the image, I got an error: “New-PSSession : This parameter set requires WSMan, and no support WSMan client library was found, or PowerShell quits with an unhandled exception

Researching I figured out there is another way to install PowerShell using HomeBrew (https://brew.sh).

To install, open Terminal and paste these lines:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Press Enter

Input your admin password, then xcode will be installed.

HomeBrew installation will be completed, then now let’s install PowerShell.

paste the follow line: brew cask install powershell to start the installation

Input again the admin password

And PowerShell has been installed on my Mac! Now I will try to connect to Exchange online.

Use the follow command to save your o365 credentials in a variable: $UserCredential = Get-Credential

then save the session information in another variable called $Session:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

As you can see, the error does not appear anymore!
The next step is start the session using: Import-PSSession $Session -DisableNameChecking

We can see that PowerShell is importing all exchange online cmdlets on this computer. To confirm, let’s get all mailboxes in my tenant.

And that’s all! I hope this process helps to all Mac users.

Tony Gonzalez

Advertisement

Where are the scripts in Exchange 2016?

Where are the scripts in Exchange 2016?
   Exchange has a folder with a complete suite of scripts that we use in the day-to-day managing activities or sometimes we are going to use only once, for example in a migration process if we need to migrate public folders to Exchange 2016 we need to use some scripts from this suite.

   In addition, there are scripts to put in maintenance mode the server in case that we need to stop the DAG due to reboot the server in order to complete a patching process or shutdown the server for another different reason.

   As well as exist the script to stop the DAG, as well exists the script to stop the maintenance mode or resume the mailbox databases copies.

   Other scripts are used to security and hygiene activities for example enable or disable antimalware, install or uninstall antispam agents.

   In the same suite we can find scripts to get metrics about the exchange organization, they have the capability to read information from the event logs of the servers in a DAG to gather information on databases mount, moves and failover over some range of time.

   In some cases, the script has a xml file with the same name with help information, this file is very helpful because you can see all the details related to the script execution, for example what king of parameters you need to include in the script execution; also,  what kind of information you need as output (data in the console, html or csv file, etc).

  The path of the scripts in Exchange 2016 is C:\Program Files\Microsoft\Exchange Server\V15\Scripts (in case you have installed Exchange in the C: drive) or you can use the exchange variable $exinstall who will send you to this directory:

   As well you can use the exchange variable $exscripts to go directly to the scripts folder in Exchange 2016
This is the directory where you can see all scripts into the server

Remember always test the scripts in another environment different to production.

Regards – Cheers – phir melenge – Hasta luego