Installing PowerShell Core on macOS and connect to Office 365 Tenant


This is the official link that explain how to do it in the Microsoft’s way :

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-6

First, we need to install “BREW”…

Open Terminal

Now, we need to install Homebrew ( see this guid: https://brew.sh )

This is the command:

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

this is the output:

when finished, run this command:

brew cask install powershell

At this point lunch  it ! 

this is the command : 

pwsh

Now , we can connect to our 365 tenant ( see this Guide:  https://marcoschiavon.net/connect-to-office-365-powershell-connect-msolservice/

Install-Module MSOnline

and then 

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection

then

Import-PSSession $Session


4 Comments

  1. Have you ever tried any Cmdlets after connecting?

    “Get-MsolAccountSku : Could not load type ‘System.ServiceModel.WSHttpBinding’ from assembly ‘System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.”

    Reply
    • Hi Robin,
      yes, there are some problems with Powershell under osx… First, you have to update your osx Powershell with this command : brew cask upgrade powershell
      I’ve done some check and i notice that, some command aren’t present..
      If i issue the Get-MsolAccountSku I have this output.. :
      S /Users/Netrek> Get-MsolAccountSku
      Get-MsolAccountSku : The term ‘Get-MsolAccountSku’ is not recognized as the name of a cmdlet,

      At this point, i think that the PShell to manage 365 under Osx is only to make some quick task and not to work ..

      Marco

      Reply
      • I use to do most daily Office 365 tasks from Powershell on Mac.
        DLs, users, calendars, meeting rooms and many others.

        So no, this can be used to accomplish most part of daily work.

        For example, room create in a bulk:
        Import-csv .\confRooms.csv | foreach{ New-Mailbox -Name $_.roomname -Room -PrimarySmtpAddress $_.emailaddress -ResourceCapacity $_.capicity -Office $_.Location}

        But when it is related to Azure’s part of my office tenant (Office based on Azure simplest Ad, you know), i have to use my windows VM.

        @robin68 – Get-MsolAccountSku is a part of msonline module which is not yet available in powershell core
        @blog – you should just try to google for “The term ‘Get-MsolAccountSku’ is not recognized as the name of a cmdlet” 🙂

        Reply
        • Thanks Yuri and sorry for the delay, but during this days i’m very busy to support a big hotel opening soon in Venice..
          Marco

          Reply

Leave a Reply

Your email address will not be published. Required fields are marked *