{"id":4498,"date":"2020-04-26T02:21:22","date_gmt":"2020-04-26T09:21:22","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=4498"},"modified":"2020-04-26T02:21:22","modified_gmt":"2020-04-26T09:21:22","slug":"office-365-cli-2-9","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/office-365-cli-2-9\/","title":{"rendered":"Office 365 CLI v2.9"},"content":{"rendered":"<p>We&#8217;ve just published a new version of the Office 365 CLI with new commands for working with and managing Microsoft 365 tenants and SharePoint Framework projects on any platform.<\/p>\n<h2>Manage Microsoft 365 and SharePoint Framework projects on any platform<\/h2>\n<p>Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Microsoft 365 and SharePoint Framework projects no matter which operating system or shell you use.<\/p>\n<p>While building solutions for Microsoft 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&#8217;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.<\/p>\n<h2>New version of Office 365 CLI &#8211; v2.9<\/h2>\n<p>Following our monthly release cadence, we&#8217;ve released a new version of the Office 365 CLI with some new capabilities and improvements.<\/p>\n<h3>Improved upgrading SharePoint Framework projects<\/h3>\n<p>With each release, SharePoint Framework introduces new capabilities. Whenever possible, you should strive to update to the latest version of the SharePoint Framework to benefit from these improvements and new features. But upgrading your project isn&#8217;t always straight-forward and involves more than just upgrading the SPFx packages. Office 365 CLI simplifies the upgrade process by scanning your project and providing you with a thorough report listing all the necessary steps to fully upgrade your project.<\/p>\n<p>In this version of the Office 365 CLI, we have done a number of improvements to upgrading SharePoint Framework projects especially around support for publishing web parts to Teams. For the complete set of improvements see the <a href=\"https:\/\/pnp.github.io\/office365-cli\/about\/release-notes\/#v290\" target=\"_blank\" rel=\"noopener noreferrer\">release notes<\/a>. We&#8217;ll continue improving the upgrade experience in the coming releases of Office 365 CLI.<\/p>\n<h3>Remove Teams tabs<\/h3>\n<p>More and more organizations use Teams to facilitate collaboration. Teams is more than just a communication tool. Thanks to its integration capabilities, you can expose other applications in Teams providing your employees with a single location to support their work.<\/p>\n<p>To ensure consistency or drive change in your Teams, you might need to change the tabs available in the different channels. To help you with that, Rabia Williams contributed a command that allows you to remove a Teams tab from the specific channel. To remove a tab execute:<\/p>\n<div class=\"language-sh highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code data-lang=\"sh\">teams tab remove <span class=\"nt\">--teamId<\/span> 00000000-0000-0000-0000-000000000000 <span class=\"nt\">--channelId<\/span> 19:00000000000000000000000000000000@thread.skype <span class=\"nt\">--tabId<\/span> 06805b9e-77e3-4b93-ac81-525eb87513b8\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>For more information about managing Microsoft Teams using the Office 365 CLI, see the documentation at <a href=\"https:\/\/aka.ms\/o365cli\" target=\"_blank\" rel=\"noopener noreferrer\">aka.ms\/o365-cli<\/a>.<\/p>\n<h3>Check the health status of the different services in Microsoft 365<\/h3>\n<p>Organizations choose Microsoft 365 for its reliability and ability to scale to support the rapid demand changes. Over the past few weeks, Microsoft 365 has been put to a test with the usage across the different services increased significantly. Microsoft 365 proved to be reliable and continues to deliver on its promise of a platform that can support organizations in digital collaboration.<\/p>\n<p>In a rare event of degraded service performance, it&#8217;s good to know of it as soon as possible and communicate it timely in your organization. Setting up automation for monitoring and alerting is crucial to keep your operations going. For this release of the Office 365 CLI, Anoop Tatti contributed a command that allows you to check the state of the different services in Microsoft 365.<\/p>\n<p>To check the status of the different services in Microsoft 365, execute:<\/p>\n<div class=\"language-sh highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code data-lang=\"sh\">tenant status list\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>For more information about managing your Microsoft 365 tenant using the Office 365 CLI, see the documentation at <a href=\"https:\/\/aka.ms\/o365cli\" target=\"_blank\" rel=\"noopener noreferrer\">aka.ms\/o365-cli<\/a>.<\/p>\n<h3>Validate SharePoint themes before applying them<\/h3>\n<p>Intranets play a crucial role in digital collaboration. They support organizations in storing information according to their business processes and governance plans and communicating with their employees. A part of the success of each intranet is how it&#8217;s perceived in the organization. Custom themes help to express the organization&#8217;s identity on the intranet and make the intranet feel &#8216;ours&#8217;.<\/p>\n<p>Modern SharePoint sites support changing the look and feel through themes. These themes are defined as JSON files that can be uploaded to your tenant by admins. And while you&#8217;re unlikely to write a whole theme manually, it&#8217;s easy to make a typo or miss a required property and get stuck in why the particular theme isn&#8217;t working.<\/p>\n<p>To help you verify that your theme will work, Garry Trinder extended the existing <code>spo theme set<\/code> command with validating the theme before applying it. If you miss a required property, specified invalid color code, or miss a comma, the CLI will warn you about rather than giving you a cryptic error code.<\/p>\n<p>For more information about working with SharePoint themes using the Office 365 CLI, see the documentation at <a href=\"https:\/\/aka.ms\/o365cli\" target=\"_blank\" rel=\"noopener noreferrer\">aka.ms\/o365-cli<\/a>.<\/p>\n<h3>Report Yammer and Microsoft 365 Groups usage<\/h3>\n<p>Many organizations that use Microsoft 365 need to track and report on how their employees use the different services provided by Microsoft. The Microsoft 365 Admin Center, as well as the admin centers dedicated to managing the different services, offer several reports that illustrate the usage from different perspectives.<\/p>\n<p>In case you need to automate reporting in scripts, Patrick Lamber continued his great work introducing commands for reporting the usage of Yammer and Microsoft 365 Groups. For more information about which reports are available, see the <a href=\"https:\/\/pnp.github.io\/office365-cli\/\" target=\"_blank\" rel=\"noopener noreferrer\">documentation<\/a>.<\/p>\n<h3>Register organizational asset library<\/h3>\n<p>Organizations using Microsoft 365 can store their branding and communication assets in an organizational asset library &#8211; a centralized location accessible to others in the organization. In each tenant, you can designate one or more libraries as organization asset libraries so that you can have for example one for the whole organization and then specific libraries, perhaps with different permissions, for the different departments.<\/p>\n<p>In this version, Albert-Jan Schot contributed a command to designate the specific document library as an organization assets library.<\/p>\n<p>To register the specific document library as an organization assets library, execute:<\/p>\n<div class=\"language-sh highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code data-lang=\"sh\">spo orgassetslibrary add <span class=\"nt\">--libraryUrl<\/span> <span class=\"s2\">\"https:\/\/contoso.sharepoint.com\/assets\"<\/span>\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>For more information about managing organization assets libraries using the Office 365 CLI, see the documentation at <a href=\"https:\/\/aka.ms\/o365cli\" target=\"_blank\" rel=\"noopener noreferrer\">aka.ms\/o365cli<\/a>.<\/p>\n<h3>New script samples<\/h3>\n<p>Office 365 CLI is a great tool both for quick adjustments to the configuration of your Microsoft 365 tenant as well as automating more complex tasks. Because Office 365 CLI is cross-platform you can use it on any OS and in any shell. To help you get started using the Office 365 CLI for automation scenarios, we started gathering some sample scripts. Here are the latest additions to the collection.<\/p>\n<blockquote><p>If you have any scripts that you use frequently, please <a href=\"https:\/\/github.com\/pnp\/office365-cli\/issues\" target=\"_blank\" rel=\"noopener noreferrer\">share them with us<\/a> so that we can learn more about the common automation scenarios.<\/p><\/blockquote>\n<h4>Scan Microsoft 365 Groups created with User&#8217;s First or Last Name<\/h4>\n<p>We can use the group naming policy to enforce a consistent naming strategy for groups created by users in our organization. A naming policy can help us and our users identify the function of the group. We can use the policy to block specific words from being used in group names and aliases. But what if we need to find out the list of Microsoft 365 groups created with the user\u2019s given name or surname as their mail?<\/p>\n<p>Joseph Velliah contributed a sample <a href=\"https:\/\/pnp.github.io\/office365-cli\/examples\/aad\/flag-groups-with-user-names\/\" target=\"_blank\" rel=\"noopener noreferrer\">script that detects Microsoft 365 Groups created with the user&#8217;s first or last name<\/a>.<\/p>\n<h4>Ensure site assets library is created<\/h4>\n<p>There are occasions when creating a new modern SharePoint site using the CLI\/REST API that the Site Assets library isn&#8217;t created, use this script to ensure that the Site Assets library is created.<\/p>\n<p>Phillip Allan-Harding contributed a sample <a href=\"https:\/\/pnp.github.io\/office365-cli\/examples\/spo\/ensure-siteassets-library\/\" target=\"_blank\" rel=\"noopener noreferrer\">script that ensures that the site assets library is created<\/a>.<\/p>\n<h4>List all tenant-wide extensions<\/h4>\n<p>Using SharePoint Framework you can build extensions that can be deployed to all sites.<\/p>\n<p>Shantha Kumar T contributed a sample <a href=\"https:\/\/pnp.github.io\/office365-cli\/examples\/spo\/list-tenant-wide-extensions\/\" target=\"_blank\" rel=\"noopener noreferrer\">script that lists all globally deployed extensions<\/a>.<\/p>\n<h2>Contributors<\/h2>\n<p>This release wouldn&#8217;t be possible without the help of (in alphabetical order) <a href=\"https:\/\/github.com\/aakashbhardwaj619\" target=\"_blank\" rel=\"noopener noreferrer\">Aakash Bhardwaj<\/a>, <a href=\"https:\/\/github.com\/VelinGeorgiev\" target=\"_blank\" rel=\"noopener noreferrer\">Velin Georgiev<\/a>, <a href=\"https:\/\/github.com\/jhagstrom\" target=\"_blank\" rel=\"noopener noreferrer\">Joakim Hagstr\u00f6m<\/a>, <a href=\"https:\/\/github.com\/phillipharding\" target=\"_blank\" rel=\"noopener noreferrer\">Phil Harding<\/a>, <a href=\"https:\/\/github.com\/ktskumar\" target=\"_blank\" rel=\"noopener noreferrer\">Shantha Kumar<\/a>, <a href=\"https:\/\/github.com\/plamber\" target=\"_blank\" rel=\"noopener noreferrer\">Patrick Lamber<\/a>, <a href=\"https:\/\/github.com\/waldekmastykarz\/\" target=\"_blank\" rel=\"noopener noreferrer\">Waldek Mastykarz<\/a>, <a href=\"https:\/\/github.com\/appieschot\" target=\"_blank\" rel=\"noopener noreferrer\">Albert-Jan Schot<\/a>, <a href=\"https:\/\/github.com\/anoopt\" target=\"_blank\" rel=\"noopener noreferrer\">Anoop Tatti<\/a>, <a href=\"https:\/\/github.com\/garrytrinder\/\" target=\"_blank\" rel=\"noopener noreferrer\">Garry Trinder<\/a>, <a href=\"https:\/\/github.com\/sprider\" target=\"_blank\" rel=\"noopener noreferrer\">Joseph Velliah<\/a> and <a href=\"https:\/\/github.com\/rabwill\" target=\"_blank\" rel=\"noopener noreferrer\">Rabia Williams<\/a>. Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it!<\/p>\n<h2>Work in progress<\/h2>\n<p>Here are some things that we&#8217;re currently working on.<\/p>\n<h3>More commands, what else<\/h3>\n<p>Microsoft 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 Microsoft 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&#8217;s possible in Microsoft 365. In the upcoming versions of the Office 365 CLI, you can expect us to add more commands across the different workloads in Microsoft 365.<\/p>\n<p>To make it easier for you to see how the CLI commands compare to the different PowerShell cmdlets, we&#8217;ve extended the <a href=\"https:\/\/pnp.github.io\/office365-cli\/about\/comparison-powershell\/\" target=\"_blank\" rel=\"noopener noreferrer\">comparison sheet<\/a> with cmdlets for Flow, PowerApps, and Teams.<\/p>\n<h3>Script examples<\/h3>\n<p>In every release of the Office 365 CLI, we introduce new commands for managing Microsoft 365. With 375 commands across the different Microsoft 365 services, the Office 365 CLI has become a powerful tool, not just for managing your tenant but also for automating your daily work.<\/p>\n<p>We&#8217;d love 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 <a href=\"https:\/\/github.com\/pnp\/office365-cli\/issues\" target=\"_blank\" rel=\"noopener noreferrer\">share them with us<\/a> so that we can learn more about the common automation scenarios.<\/p>\n<h3>Consolidate site commands<\/h3>\n<p>To improve usability and offer a new set of features, SharePoint introduced the concept of modern sites. While in theory, they&#8217;re still site collections, they&#8217;re created and managed in a slightly different way. Additionally, if you choose to create a modern team site, your site will be linked to a Microsoft 365 Group.<\/p>\n<p>Because of the differences between modern and classic sites, we&#8217;d offer two sets of commands to manage them: <code>spo site<\/code> and <code>spo site classic<\/code>. While there are indeed some differences, there are also similarities and in the end, we believe that having separate commands is irrelevant to our users. So to simplify things, we decided to consolidate the functionality of <code>spo site classic<\/code> commands into their <code>spo site<\/code> equivalents. When the consolidation is done, we&#8217;ll deprecate <code>spo site classic<\/code> commands and remove them in v3 of the Office 365 CLI.<\/p>\n<p>Our goal is to keep all functionality intact. If you have any concerns about this decision, please don&#8217;t hesitate to <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\" target=\"_blank\" rel=\"noopener noreferrer\">let us know<\/a>.<\/p>\n<h3>Introduce convenience <code>get<\/code> commands<\/h3>\n<p>One of the scenarios for using the CLI is to get information about a specific object in Microsoft 365: a site, team, flow, etc. Typically, before you can get to that information, you need to execute the corresponding <code>list<\/code> command to retrieve all available objects, copy the ID of the object that you&#8217;re interested in, and paste it to the corresponding <code>get<\/code> command.<\/p>\n<p>We&#8217;ve been thinking about simplifying this workflow by <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\/1476\" target=\"_blank\" rel=\"noopener noreferrer\">extending the <code>get<\/code> commands<\/a>. If you don&#8217;t specify the identity of an object that you will retrieve, the CLI will present you with a list of all available objects (or objects that match your filter). After selecting the specific object, the CLI will then retrieve it for you and show its properties without you having to run the <code>list<\/code> command separately and copy &amp; paste the object&#8217;s identifier between commands.<\/p>\n<p>Would this be helpful for you? <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\/1476\" target=\"_blank\" rel=\"noopener noreferrer\">Let us know!<\/a><\/p>\n<h3><code>ensure<\/code> commands<\/h3>\n<p>Currently, Office 365 CLI has dedicated commands for retrieving, creating, and updating resources. If you were to create a script that ensures a specific configuration, for each resource you&#8217;d need to see if it exists, create it if it doesn&#8217;t, or update it if it does.<\/p>\n<p>We&#8217;re thinking about simplifying this scenario by introducing commands with a new verb named <code>ensure<\/code>. For example, to ensure that a particular site collection exists, instead of executing a combination of <code>spo site list<\/code>\/<code>spo site get<\/code>, <code>spo site add<\/code> and <code>spo site set<\/code>, you&#8217;d execute <code>spo site ensure<\/code> with the necessary parameters which would automatically verify if the particular site exists and matches your configuration. If the site doesn&#8217;t exist, it would create it. If it does, the command would check if the properties you specified to match the retrieved site and update them if necessary.<\/p>\n<p>We&#8217;ll start to <a href=\"https:\/\/github.com\/pnp\/office365-cli\/issues\/1404\" target=\"_blank\" rel=\"noopener noreferrer\">implement this idea<\/a> on the <code>spo site<\/code> commands. We&#8217;d love to <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\" target=\"_blank\" rel=\"noopener noreferrer\">hear from you<\/a> if it&#8217;s something that you&#8217;d find helpful and what other objects we should take into account.<\/p>\n<h3>Setting arbitrary properties on SharePoint objects<\/h3>\n<p>At this moment, the most of SharePoint <code>set<\/code> commands in the Office 365 CLI support only a handful of options that correspond to the properties of their SharePoint class, like <code>Web<\/code>, <code>Site<\/code>, <code>List<\/code>, etc. This is similar to how the <code>Set-PnP*<\/code> cmdlets work. However, because PnP PowerShell works with CSOM, this limitation there is often circumvented, by retrieving the CSOM object, updating its properties, and calling <code>$object.ExecuteQuery()<\/code> to persist the changes outside of PnP cmdlets. Because the CLI doesn&#8217;t use CSOM, this isn&#8217;t possible and users are limited to using whatever options are exposed by the CLI commands.<\/p>\n<p>We&#8217;re thinking about addressing this limitation by allowing you to set the value of any property exposed on the SharePoint object. This would work only for properties that have values of simple types like <code>bool<\/code>, <code>string<\/code> or <code>int<\/code> because complex values likely can&#8217;t be serialized to <code>string<\/code> without additional logic.<\/p>\n<p>We would offer rudimentary logic of checking if the specified properties are valid, by examining the latest version of the SPO CSOM assemblies and checking which properties on the particular SharePoint class have setters and values of the supported types and thus can be used.<\/p>\n<p>What do you think of this approach? Would this help to solve a problem you have? In the previous release, we have extended the <code>spo web set<\/code> command with this functionality. We&#8217;d love you to try it and <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\" target=\"_blank\" rel=\"noopener noreferrer\">tell us what you think<\/a>.<\/p>\n<h2>Try it today<\/h2>\n<p>Get the latest release of the Office 365 CLI from npm by executing in the command line:<\/p>\n<div class=\"language-sh highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code data-lang=\"sh\">npm i <span class=\"nt\">-g<\/span> @pnp\/office365-cli\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p>If you need more help getting started or want more details about the commands, the architecture, or the project, go to <a href=\"https:\/\/aka.ms\/o365cli\" target=\"_blank\" rel=\"noopener noreferrer\">aka.ms\/o365cli<\/a>. If you see any room for improvement, please, don&#8217;t hesitate to reach out to us either on <a href=\"https:\/\/github.com\/pnp\/office365-cli\/discussions\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub<\/a> or <a href=\"https:\/\/twitter.com\/office365cli\" target=\"_blank\" rel=\"noopener noreferrer\">twitter<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve just published a new version of the Office 365 CLI with commands for managing Office 365 tenants and SharePoint Framework projects on any platform.<\/p>\n","protected":false},"author":69079,"featured_media":4317,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[128,11],"tags":[53,140,19],"class_list":["post-4498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-teams","category-office-add-ins","tag-office-365","tag-office-365-cli","tag-sharepoint-framework"],"acf":[],"blog_post_summary":"<p>We&#8217;ve just published a new version of the Office 365 CLI with commands for managing Office 365 tenants and SharePoint Framework projects on any platform.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69079"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=4498"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/4498\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/4317"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=4498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=4498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=4498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}