Office 365 CLI v2.2


We’ve just published a new version of the Office 365 CLI with new commands for working with and managing Office 365 tenants and SharePoint Framework projects on any platform.

Manage Office 365 and SharePoint Framework projects on any platform

Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 and SharePoint Framework projects no matter which operating system or shell you use.

While building solutions for Office 365 expands beyond the Windows operating system, managing many of the platform settings is possible only through PowerShell on Windows. As more and more users work on non-Windows machines, it’s inconvenient for them to have to use a Windows virtual machine to configure their tenants. With the Office 365 CLI, you can configure your tenant no matter which operating system you use. Additionally, using Office 365 CLI, you can manage your SharePoint Framework projects.

New version of Office 365 CLI - v2.2

Following our monthly release cadence, we’ve released a new version of the Office 365 CLI with some new capabilities.

Get Office 365 Groups usage reports

As organizations go to Office 365 and use Office 365 Groups, they often wonder to what extent the different Groups are being used and if any unused Groups could be archived to clean up clutter and simplify finding the right information.

For this release of Office 365 CLI, Joseph Velliah continued his work on the usage reporting commands for the Office 365 CLI and contributed commands and contributed three new report commands.

To get details about Office 365 Groups activity by group for the last week, execute:

aad o365group report activitydetail --period D7

To get the number of group activities across group workloads for the last week, execute:

aad o365group report activitycounts --period D7

To Get the daily total number of groups and how many of them were active based on activities for the last week, execute:

aad o365group report activitygroupcounts --period D7

For more information about getting Office 365 usage reports using the Office 365 CLI, see the documentation.

Remove Flows

Microsoft Flow is one of the most powerful services in Office 365. Being used by everyone, from IT professionals to non-IT employees, Microsoft Flow helps people to automate routine work and spend time on what truly matters. Not surprisingly, many organizations have seen a significant increase in the usage of Flow in their tenants.

As the Flow adoption increases, you might need to clean up Flows at scale. Either if they are no longer used or use premium features while your organization has no premium licenses. To help you automate removing Flows, Garry Trinder contributed a command that allows you to easily remove Flows.

To remove a Flow, execute:

flow remove --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --name 3989cb59-ce1a-4a5c-bb78-257c5c39381d

For more information about managing Flows using the Office 365 CLI, see the documentation.

Work with PowerApps components on any platform

Another service that’s been gaining a lot of popularity over the past months is PowerApps. Using PowerApps, non-developers can build applications to automate their business processes.

PowerApps is pretty powerful and its capabilities range from building simple apps, to building reusable components and packaged applications targeting professional developers.

For this version of the Office 365 CLI, Yannick Reekmans continued his work on PowerApps in the Office 365 CLI, upgrading the code to match the latest version of the PowerApps PCF CLI and contributing an additional command to add a reference to a PCF project to a PCF solution.

To reference an existing PCF project from a solution, execute:

pa solution reference add --path ./projects/ExampleProject

For more information about working with PowerApps using the Office 365 CLI, see the documentation.

Update SharePoint app pages

A part of Microsoft’s investments in the modern SharePoint UI was the introduction of app pages, which developers can use to deploy their applications in a managed way. In contrary to regular pages, users can’t edit app pages and an app page can contain only one SharePoint Framework Web Part.

For this release of the Office 365 CLI, Rabia Williams contributed a command that allows updating app pages and specifying which SharePoint Framework Web Part should be displayed on it.

To updated a SharePoint app page, execute:

spo apppage set --webUrl "https://contoso.sharepoint.com" --pageName "Contoso.aspx" --webPartData $webPartData

For more information about managing modern SharePoint pages using the Office 365 CLI, see the documentation.

Get replies to Microsoft Teams messages

Many organizations who are on Office 365, use Microsoft Teams to facilitate collaboration. In many cases, Teams are more effective than e-mail and through its reach integration capabilities allow organizations to provide their employees with a single interface for their daily work.

For this release of the Office 365 CLI, Bruce Albany contributed a command that allows you to retrieve replies to a specific Microsoft Teams message. This is perfect for reporting or automation purposes.

To retrieve replies to a specific Microsoft Teams message, execute:

teams message reply list --teamId 5f5d7b71-1161-44d8-bcc1-3da710eb4171 --channelId 19:88f7e66a8dfe42be92db19505ae912a8@thread.skype --messageId 1540747442203

For more information about working with Microsoft Teams using the Office 365 CLI, see the documentation.

Manage Yammer on any platform

Organizations on Office 365 have plenty of choices when it comes to how to facilitate their collaboration. They can choose the good old e-mail, but also can use services like Microsoft Teams or Yammer. Each of these services shines in one or more specific scenarios and there is no right or wrong when it comes to using them in the workplace.

In this release of the Office 365 CLI, we’re proud to introduce support for Yammer. Patrick Lambert contributed two commands to list Yammer networks for the current user and get information about a specific user.

To get information about Yammer networks for the current user, execute:

yammer network list

To get information about the current user, execute:

yammer user get

To find a user with the specified e-mail address, execute:

yammer user get --email john.smith@contoso.com

Since Yammer is not available in all tenants, we made its permissions optional in the Azure AD app used by the Office 365 CLI. Before you can start using Yammer commands in the Office 365 CLI, you need to consent the Azure AD app access to Yammer by executing:

consent --service yammer

Patrick has ideas for adding more Yammer commands to the Office 365 CLI which you can expect in future releases.

For more information about managing Yammer using the Office 365 CLI, see the documentation.

Manage SharePoint Features

Every week Microsoft releases updates in Office 365. Some are minor tweaks, some release new features. In some cases, to add these new capabilities to your existing sites, you might need to activate a specific Feature.

To help you automate managing SharePoint Features, Stijn Brouwers contributed to this release of the Office 365 CLI a command to enable SharePoint Features.

To enable a SharePoint Feature, execute:

spo feature enable --url https://contoso.sharepoint.com/sites/sales --featureId 915c240e-a6cc-49b8-8b2c-0bff8b553ed3 --scope Site

For more information about managing SharePoint Features using the Office 365 CLI, see the documentation.

Contributors

This release wouldn’t be possible without the help of (in alphabetical order) Bruce Albany, Stefan Bauer, Stijn Brouwers, Velin Georgiev, Bassem Khalil, Patrick Lamber, Yannick Reekmans, Garry Trinder, Joseph Velliah and Rabia Williams. Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it!

Work in progress

Here are some things that we’re currently working on.

More commands, what else

Office 365 is evolving and new capabilities are being released every day. With the Office 365 CLI, we aim to help you manage your tenant on any platform in a consistent way, no matter which part of Office 365 you interact with. While we keep adding new commands to the Office 365 CLI each release, we still barely scratched the surface with what’s possible in Office 365. In the upcoming versions of the Office 365 CLI, you can expect us to add more commands across the different workloads in Office 365.

To make it easier for you to see how the CLI commands compare to the different PowerShell cmdlets, we’ve extended the comparison sheet with cmdlets for Flow, PowerApps, and Teams.

Script examples

In every release of the Office 365 CLI, we introduce new commands for managing Office 365. With 275 commands across the different Office 365 services, the Office 365 CLI has become a powerful tool, not just for managing your tenant but also for automating your daily work. In the coming weeks, we want to spend some time to show you how you can use the Office 365 CLI to build automation scripts in PowerShell Core and Bash. If you have any scripts using SPO or PnP PowerShell that you use frequently, please share them with us so that we can learn more about the common automation scenarios.

Office 365 CLI is a powerful tool that helps you to manage your Office 365 tenant. With each version, we add new commands making it more powerful and helping you to have a single tool for all your needs. The downside is, that supporting all these commands, requires the CLI to have a high-level of permissions. At this moment, no matter which set of commands you use, we require you to consent a lot of permissions before you can start using the Office 365 CLI. While it’s acceptable for some, it’s a no-go for others. What if we could change this?

In this release of the Office 365 CLI, we introduced support for Yammer. Since Yammer is not present in all tenants, we couldn’t include it in the default set of permissions. Instead, we introduced the ability to add Yammer permissions to the Office 365 CLI Azure AD app. If you don’t use Yammer or even don’t have it in your tenant, you’re not asked to consent Yammer permissions. If you want to use the Office 365 CLI to manage Yammer in your tenant, you can add the necessary permissions, by executing consent --service yammer. What if we used the same approach with all other services?

What if by default, the Office 365 CLI Azure AD app would have only permissions to allow you to sign in. Then, depending on which commands you want to use, you would grant additional permissions, executing consent --service spo or consent --service aad. To keep things simple, we would keep track of which permissions are needed for each service and you would then consent to manage the particular service. To quickly consent all permissions, we could introduce a convenient option, like consent --all.

What do you think of this approach? Would this help to solve a problem you have or would it introduce an unnecessary complexity? We’d love to hear from you, either in the comments below or on twitter @office365cli.

Try it today

Get the latest release of the Office 365 CLI from npm by executing in the command line:

npm i -g @pnp/office365-cli

If you need more help getting started or want more details about the commands, the architecture or the project, go to aka.ms/o365cli. If you see any room for improvement, please, don’t hesitate to reach out to us either on GitHub, on twitter with the #office365cli hashtag or on gitter.

Others found also helpful: