Office 365 CLI v1.1.0
We have published the v1.1.0 of the Office 365 CLI with new commands for managing Office 365 tenants on any platform.
Manage Office 365 on any platform
Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 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.
New version of Office 365 CLI - v1.1.0
Continuing the effort of extending the CLI, we bring you a new version with new commands for managing your Office 365 tenant. Since we didn’t have any breaking changes in this release, we only have a minor version number increase. Still, we have some cool updates for you. See for yourself.
Manage Microsoft Flow flows with the Office 365 CLI
More and more organizations every day start using the Microsoft Flow. And, while it remains primarily and end-user tool, at some point you will want to be able to manage Flows in your organization. In this release we added support for connecting to the Azure Management Service that exposes a set of commands to manage Microsoft Flow flows.
Start, by connecting to the Azure Management Service using the azmgmt connect
command:
o365$ azmgmt connect
Once you’re authenticated, get the list of Microsoft Flow environments in your tenant by executing:
o365$ azmgmt flow environment list
Next, for the specific environment, list all Flows:
o365$ azmgmt flow list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5
If you want to see Flows owned by other users as well, add the --asAdmin
option:
o365$ azmgmt flow list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --asAdmin
For each Flow, you can get additional information, by executing:
o365$ azmgmt flow get --name 1c6ee23a-a835-44bc-a4f5-462b658efc13 --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5
Again, if this is a Flow you don’t own, don’t forget to add the --asAdmin
option to the command.
In this release, we introduced the ability to get information about Microsoft Flow flows in your tenant. In the future releases, you can expect additional commands that will allow you to export and import Flows.
The API that makes it possible for the Office 365 CLI to manage Flows is in preview. There is a chance that it will change in the future, which could require changes to Office 365 CLI commands and their output. In case of such change, we’ll communicate it timely, allowing you to adjust your automation scripts accordingly.
For more information and examples of getting information about Microsoft Flow flows in your tenant using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Manage Office 365 Groups
Office 365 Groups are one of the fundamental building blocks in Office 365 that bring together a number of collaboration capabilities giving Office 365 users a single place to work.
In the previous version of the Office 365 CLI we introduced the first set of commands to work with Office 365 Groups in your tenant. In this release, Albert-Jan Schot from Mavention did an awesome job adding commands to remove Office 365 Groups and manage and restore removed groups.
To list removed Office 365 Groups in your tenant, execute:
o365$ graph o365group list --deleted
Then, you can restore any of the deleted Office 365 Groups by executing:
o365$ graph o365group restore --id 28beab62-7540-4db1-a23f-29a6018a3848
For more information about managing Office 365 Groups using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Get information about site classification configuration
When working with modern sites in Office 365, you can specify the classification level of the information stored in that site. By classifying a site, you not only clearly communicate to all users how they should handle the information in that particular site, but also make it possible to adequately automate governance and management of information in your tenant.
In this version of the Office 365 CLI, Balamurugan Kailasam contributed a command to get the site classification configuration in your tenant.
To get the information about site classification configuration in your tenant, first connect to the Microsoft Graph by executing:
o365$ graph connect
Next, get the information about site classification configuration using:
o365$ graph siteclassification get
In the future releases you can expect the Office 365 CLI to allow you to not only get the information about site classification configuration in your tenant but also to set it up.
For more information about retrieving information about site classification configuration in your tenant using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Manage Office 365 themes
Using the new Office 365 themes, site owners can apply custom styles and colors to their sites. This helps them to reinforce their brand image and provide site users with a consistent look and feel across the organization.
In this version of the Office 365 CLI, Rajesh Sitaraman from SADA Systems did a great job of delivering a full set of commands to manage Office 365 themes. Thanks to his contribution, you can not only get information about existing themes, but also create and update new ones.
To get information about Office 365 themes in your tenant, execute:
o365$ spo theme list
If you want to create a new theme for your organization, create the theme using the Theme Generator and upload it to your tenant, by executing:
o365$ spo theme set -n Contoso-Blue -p /Users/rjesh/themes/contoso-blue.json
For more information and examples on using the Office 365 CLI to manage Office 365 themes in your tenant, see the documentation at aka.ms/o365-cli.
Apply Site design to an existing site
Site designs are the new way organizations can build custom site templates in Office 365. Using site designs, they can align with the preferred look and feel and structure as defined in the organizational information architecture.
Typically, site designs are used when creating new sites. When creating the site, SharePoint would apply the site design selected by the user. But if you had to change the site design after the site has been created, your changes wouldn’t be applied to existing sites.
In this version of the Office 365 CLI, Paweł Hawrylak from Sii Poland, contributed the spo sitedesign apply
command that allows you to apply a site design to an existing site:
o365$ spo sitedesign apply --id 9b142c22-037f-4a7f-9017-e9d8c0e34b98 --webUrl https://contoso.sharepoint.com/sites/project-x
Using this command, you can apply site designs to existing sites, ensuring consistency of customizations and branding across your whole tenant.
For more information and examples on using the Office 365 CLI to manage site designs in your tenant, see the documentation at aka.ms/o365-cli.
Work with property bag values
If you build a SharePoint solution and need to store configuration data in a place where it cannot be easily modified by end-users, property bag is a very convenient location to use.
In the previous version of the Office 365 CLI, we introduced a set of commands to get information about the property bag values in your sites. In this release, Velin Georgiev continued his work, contributing a command to remove a property bag value.
To remove a property bag value using the Office 365 CLI, execute:
spo propertybag remove --webUrl https://contoso.sharepoint.com/sites/test --key key1
Velin is currently working on the command to set property bag values. Once he completes his work, the Office 365 CLI will have a full support for managing property bag values.
For more information and examples on using the Office 365 CLI to manage property bag values, see the documentation at aka.ms/o365-cli.
Retrieve files
When managing your tenant, you might need to perform some operations on files. For this release, Robert Schouten from Wortell continued his work on files-related commands in the Office 365 CLI, contributing a command to retrieve the specified file, its properties or its contents from your tenant.
To get the properties of a file stored in one of your document libraries, execute:
o365$ spo file get --webUrl https://contoso.sharepoint.com/sites/project-x --url '/sites/project-x/documents/Test1.docx'
If you want to download that file, use the --asFile
option specifying the local path where the file should be saved using the --path
option:
spo file get --webUrl https://contoso.sharepoint.com/sites/project-x --url '/sites/project-x/documents/Test1.docx' --asFile --path /Users/user/documents/SavedAsTest1.docx
For more information and examples on managing files in your sites using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Get information about subsites
We are on the verge of big changes to how organizations implement information architecture in SharePoint and Office 365 and which building blocks they use to facilitate collaboration. Where in the past, you would frequently see hierarchical structures with a site collection and many subsites, nowadays you could consider using separate site collections. Hub sites, recently released to preview, connect the different site collection together. Still, today many organizations use subsites and we wanted the CLI to help you manage them, whether it’s for your daily operations or preparations for migrations.
In this release, Paul Keijzers from Wortell contributed a command which you can use to get information about a specific subsite:
o365$ spo web get --webUrl https://contoso.sharepoint.com/subsite
For more information and examples on working with subsites using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Manage modern pages
As organizations move to using the modern SharePoint experience, the need to manage modern pages increases. In this release, we are proud to introduce the first set of commands to manage modern pages in your sites.
Using the spo page list
command, you can retrieve the list of all modern pages in the specific modern site:
o365$ spo page list --webUrl https://contoso.sharepoint.com/sites/team-a
Next, you can create a new modern page, by executing:
o365$ spo page add --name new-page.aspx --webUrl https://contoso.sharepoint.com/sites/a-team
If you need to change one or more page properties, you can use the spo page set
command:
o365$ spo page set --name page.aspx --webUrl https://contoso.sharepoint.com/sites/a-team --layoutType Article
In the future releases of the Office 365 CLI, you can expect more commands related to managing modern pages and their contents.
For more information and examples on managing modern pages using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Contributors
This release wouldn’t be possible without the help of (in alphabetical order) Velin Georgiev, Paweł Hawrylak, Balamurugan Kailasam, Paul Keijzers, Albert-Jan Schot, Robert Schouten and Rajesh Sitaraman.
Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it. It’s a real pleasure to work with you.
What’s next
Over the last few weeks we’ve been discussing and researching a couple of things.
Additional ways to authenticate with Office 365
Initially, when we released the Office 365 CLI, we provided the device code flow, as the only way to authenticate against Office 365. When you execute a command in the Office 365 CLI, to connect to an Office 365 service, such as SharePoint, the CLI will reach out to Azure AD, obtain a device code, present it to you in your command line prompting you to open your web browser, navigate to a specific Azure AD login page and present that code. This flow is perfect for command-line tools and allows you to benefit of advanced authentication features such as multi-factor authentication or conditional access. The one downside is, that it requires user interaction, which is hard to do, if you want to use the CLI in continuous integration/deployment scenarios for example. Recently we’ve been working on refactoring the authentication implementation in the Office 365 CLI and providing additional authentication flows. Stay tuned for more updates in this area in the upcoming beta versions of the Office 365 CLI.
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. So far, we 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.
Managing SharePoint Framework projects
What if you could use the Office 365 CLI not only to manage your Office 365 tenant but also to improve the developer experience of your Office 365 solutions?
Another area, that we’ve been researching recently, is the ability for the Office 365 CLI to manage your SharePoint Framework projects. SharePoint Framework is a popular development model backed by a vibrant community and there are some great opportunities for the CLI to improve how you build solutions. We should have something to show you relatively fast and stay tuned for updates.
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.