Office365 CLI – managing Office365 on any platform

Aside

In these challenging times, one might find themselves in a situation where they need to carry out operations upon their MicroSoft Office365 tenancies, on something else other that windows.

There is PowerShell, a hugely powerful way to administer Office365, but it will only run on windows, it also requires setting up, various modules have to be loaded, credentials managed moreover scripts have to be crafted taking time.

So I have found that I am in a situation using a Mac remotely.  Office365 CLI provides versatile commands to administer the gamut of Office365 Apps from SharePoint to Teams.

Example, getting reports on teams for a given tenancy

o365$ teams team list

or a list of all site collections

o365$ spo site classic list

checking stats of a connection

o365$ status

issuing commands directly to the terminal piping out to a file

o365 teams team list > /Users/development/Desktop/teamsExample.txt

issuing commands directly to the terminal piping out to a json file

o365 teams team list > /Users/development/Desktop/teamsExample.json

Here’s what can be managed using Office365 CLI

Office 365 CLI v2.8.0  
Manage Microsoft Office 365 and SharePoint Framework projects on any platform  
Commands:
 help [command...]   Provides help for a given command.
 exit|quit           Exits application.
 version             Shows the current version of the CLI
 consent [options]   Consent additional permissions for the Azure AD application used by the Office 365 CLI
 login [options]     Log in to Office 365
 logout [options]    Log out from Office 365
 status [options]    Shows Office 365 login status
Command Groups:
  aad *               35 sub-commands.
  accesstoken *       1 sub-command.
  cli *               5 sub-commands.
  flow *              12 sub-commands.
  graph *             5 sub-commands.
  onedrive *          7 sub-commands.
  outlook *           13 sub-commands.
  pa *                5 sub-commands.
  planner *           1 sub-command.
  skype *             3 sub-commands.
  spfx *              3 sub-commands.
  spo *               215 sub-commands.
  teams *             41 sub-commands.
  tenant *            4 sub-commands.
  util *              1 sub-command.
  yammer *            9 sub-commands.

Installation

Top tip, create an additional Mac User account with admin rights if you can to carry out all this work.

MacOS Users & Groups
MacOS Users & Groups

Goto https://brew.sh and follow the instructions to download HomeBrew on a Mac.  You will need to paste the command in from the page into a Terminal prompt.  I have not shown the command here as it has changed over time.

Once installed in the terminal window type

brew install node

Check node and npm are installed using the terminal by issuing

node -v

and

npm -v

The result is that you will see three part version numbers.

To install the Microsoft Office 365 CLI, follow the reference page’s instructions, ultimately typing the following in the terminal window.

npm install -g @pnp/office365-cli

Bonus installation, Linux

I have a raspberry pi, with Ubuntu 19.2 on it, Iwondered if the Office365 CLI would work on it? I issued the following commands in a terminal prompt.  I haven’t tried this using ssh as it involves a step where we need to open a web browser to authenticate, so over secure shell or on a headless linux box that is going to be hard!

sudo apt install git
sudo apt install curl

Then install a package manager for node e.g Homebrew or chocolatey if you like, since I prefer beer, I issued the following in a terminal prompt. You can ponder over chocolate of beer.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" `

After download and installation has completed type the following in the terminal session.

sudo apt-get install build-essential
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> /home/osboxes/.profile
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
brew install gcc

Now install node, type the following in a terminal

brew install node

So at this point we have node and crucially node package manager, npm, so we can install the Office365. CLI
Type the command into the terminal

npm install -g @pnp/office365-cli

To test type o365 at the terminal prompt, follow the instructions to authenticate using a web browser and the code, login with credentials we can now retrieve all the Sharepoint site collections using

spo site list

Example result…

Title Url
TestSite https://abctenant.sharepoint.com/sites/Site
TestSite1 https://abctenant.sharepoint.com/sites/Site1
PlanA https://abctenant.sharepoint.com/sites/PlanA

SharePoint migration from MySites to OneDrive for Business and UCISA bursary

BLOG entry syndicated from my other BLOG that runs on GHOST

I maintain a set of PowerShell scripts and processes to migrate many MySites from SharePoint 2010 to OneDrive for business.

As we know, PowerShell can automate many processes that you could perform using the user interfaces of SharePoint on premise or in the cloud.

So general idea is to

  • use a mapping file, where we have at least two columns. Column A in the windows on-premise username. Column B is the o365 login. I do have a third column, which is the destination OneDrive, but since this is almost usually the OneDrive logon, where any ‘@’ or ‘.’ are escaped as ‘_’
  • populate this file or database table with the users that you want to migrate
  • using PowerShell iterate through this list and
  • set users on-premise MySite to read only – I upload a separate master page and change the page status for this
  • in o365, assume the user is setup, licensed and provisioned. We use an account that has global admin rights in o365
  • in o365, make sure that the global admin has access to the users OneDrive by adding it as a secondary admin
  • use ShareGate PowerShell to migrate the data. I know this is a cheat, but there a many reasons to use ShareGate such as insane mode, using Azure Storage and logging. Some other thoughts on   Azure Storage
  • when content has migrated successfully, timestamp the user profile on-premise with a date migrated value – later on we deploy some timer jobs to with delete or recycle after a specified time period.

Take a sneak peek at the repo. This is some code that I prepared for the dev.ac.uk  event co-hosted by JISC and UCISA in February 2018. Slides, here.

Much of the knowledge I accrued in order to do this as a result of being awarded a UCISA bursary that paid the costs of travel, conference entrance fee and accommodation to MicroSoft IGNITE 2017.

I strongly suggest that if you do work in IT for a UK Higher Education institution, that you apply for the bursary yourself. Where this particularly helped is that I attended sessions about the latest developments in PowerShell, the tooling and Office365. I found it particularly valuable to meets engineers from Microsoft Azure, ShareGate, MetaLogix  and other vendors of migration products.

The only downside is that it is a corporate event, so one particular query about how and when any throttling of content into and out of Office365 may occur didn’t really get any answers from MicroSoft, as I guess this kind of detail is a trade secret, I get that.

ShareGate offered some good advice on their experience with organisation way bigger than my institution, in that if you use their tools to manually migrate, use different tabs for different migration tasks. If using it in its PowerShell guise, then split the job up. Although managing that particular task would be a challenge in terms of organisation. I guess you could containerise the server using say docker, but ShareGate licenses would be needed for those individual containers I guess.

Another aspect of IGNITE is the sheer scale if it. I had planned to attend various sessions, but this wasn’t always possible due to sessions being placed far apart, overcrowding at some times and the warm weather. If I went again, I would be prepared for that though.

 

 

Expo

Mission today, is to network and try to get the low down on some on some issues that my team and I are interested in.  This means that we go to various Expo stands and talk with vendors such as ShareGate, Microsoft, Zerto  and take demos from Sporganizer amongst others.

  • what’s the throttling situation in Office365?
  • approaches in Microsoft Teams governance

but more importantly, collect swag such as SharePoint socks the team are gonna love these.

Microsoft IGNITE and Microsoft teams

Day 2 of MS IGNITE 2017 in Orlando.

Day one was all about orientation both personally and within the strategy of Microsoft.

Yesterday we saw some keynotes around AI, machine learning, augmented reality and the importance of social graphs.

More related to my specialism is collaboration in the Office so I attended a keynote around the Microsoft Teams product.  During the keynote,  some announcements were made and use cases shown.  An interesting interview on its rollout at Accenture and another large organisation.  The demo of Microsoft teams showed a compelling product enabling collaboration in the workplace for staff including external folk.  A controversial statement around its design rationale was that it was aimed at millennial who work in a different way – I would have stayed away from such a statement.

One of the challenges of a conference of this size is that it is difficult to coordinate going from session to session as there might be a long walk.  I have decided not to necessarily stick to sessions around my specialisms, but to broaden.  I am about to go into a deeper dive session around teams “Collaborate in a chat based workplace using Microsoft teams”.

Later yesterday in an evening session, Benjamin Niaulin (@bniaulin) discussed the various classification of collaboration products and we saw that Microsoft Teams is a different use case from “classic” SharePoint (your bread and butter teamsites etc.) and Modern SharePoint.  It’s more like a workplace Facebook messenger, an evolution of Skype for business.  I took a picture of a compelling slide, but do to the sheer busyness of the event, some of is content is hidden.

Microsoft collaboration products classified by Benjamin Niaulin of ShareGate.  Here we see five classes: Conversations, where Teams sits, Meetings, Site & File, where SharePoint sits, Task Management and Others such as OneNote and Power BI.  A useful diagram in my opinion.

 

I’ll post more after some sessions today.

 

MicroSoft IGNITE September 2017, Orlando, Florida

Link

Welcome to this blog..

I have been lucky enough to be awarded a bursary for travel and costs for MicroSoft IGNITE courtesy of UCISA   Moreover, I have been invited to sessions to contribute to the roadmap of SharePoint and OneDrive.

I have asked colleagues at the University on their views and thoughts.  A couple of significant questions we’d like some insight on are:

  • anecdotally, we have heard that there is a 16GB upload limit per Office365 tenancy.  Is that right? How does that work with “business as usual” traffic?
  • there are some great new “templates” in SharePoint Online, such as Planner, Groups and Teams.  unlike common or garden site collections, we cannot see these as site collections in the usual way in the sharepoint admin area.  How can an organisation manage and govern such sites?  Additionally it would be great if we could set the default to be private during creation.  Yet we understand that these templates have been conceived to please the majority.

Another thought:  through observation of users one drive and the rationale of setting these so that only the user can see files?  In a script that i wrote to migrate SharePoint MySites to OneDrive, I had to explicitly and the SharePoint Admin as a secondary admin.  This is so that we can access their files in order that we can provide governance and support of the content.  Out of curiosity, why can’t an admin do that by default?

Planner screenshot

Planner screenshot