{"id":5518,"date":"2020-11-02T01:00:10","date_gmt":"2020-11-02T09:00:10","guid":{"rendered":"https:\/\/officedevblogs.wpengine.com\/?p=5518"},"modified":"2020-11-02T01:00:10","modified_gmt":"2020-11-02T09:00:10","slug":"cli-microsoft-365-3-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/cli-microsoft-365-3-2\/","title":{"rendered":"CLI for Microsoft 365 v3.2"},"content":{"rendered":"<p>We\u2019ve just published a new version of the CLI for Microsoft 365 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>CLI for Microsoft 365 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\u2019s inconvenient for them to have to use a Windows virtual machine to configure their tenants. With the CLI for Microsoft 365, you can configure your tenant no matter which operating system you use. Additionally, using CLI for Microsoft 365, you can manage your SharePoint Framework projects.<\/p>\n<h2>New version of CLI for Microsoft 365 \u2013 v3.2<\/h2>\n<p>Following our monthly release cadence, we\u2019ve released a new version of the CLI for Microsoft 365 with some new capabilities. Here are a few of the most noteworthy additions.<\/p>\n<h2>Changes<\/h2>\n<p>In this release, we have made changes to the internal code of CLI.<\/p>\n<h3>Removal of Vorpal<\/h3>\n<p>When we started building CLI for Microsoft 365, we used <code>Vorpal<\/code> to get the basic CLI functionality such as git-style commands, aliases, parsing arguments, help, etc. Unfortunately, over time Vorpal got less and less active support and the repository became stale.<\/p>\n<p>To avoid using outdated dependencies, we decided to remove Vorpal and build the necessary functionality ourselves. Aside from decreasing security risks, this allows us greater functionality as we now control how commands are executed and how they return output.<\/p>\n<p>As a user of CLI for Microsoft 365 you shouldn\u2019t see any negative effect of this change. What\u2019s more, in the future versions of CLI for Microsoft 365 you can expect enhancements that will make working with the CLI more intuitive and convenient.<\/p>\n<h3>Replacing <code>request<\/code> with <code>axios<\/code><\/h3>\n<p>When we started building CLI for Microsoft 365, we used the <code>request<\/code> npm package to help simplify the HTTP calls made to Microsoft 365 APIs.<\/p>\n<p>Unfortunately, request was placed in maintenance mode and has since been deprecated, since 11th February 2020 no changes have been made to the library.<\/p>\n<p>To avoid using outdated dependencies, we decided to remove request and replace it with axios.<\/p>\n<p>As a user of CLI for Microsoft 365 you shouldn\u2019t see any negative effect of this change. What\u2019s more, in the future versions of CLI for Microsoft 365 you can expect enhancements that will make working with the CLI more intuitive and convenient.<\/p>\n<h2>New Commands<\/h2>\n<h3>Retrieve SharePoint Knowledge Hub site<\/h3>\n<p>Preparing for the rollout of Knowledge Hub Sites, Arjun Menon contributed a command that lets you retrieve the knowledge hub site in your tenant.<\/p>\n<p>To retrieve a knowledge hub site for your tenant, execute:<\/p>\n<pre><code class=\"language-sh\">m365 spo knowledgehub get\n<\/code><\/pre>\n<h3>Retrieve Microsoft Teams Tab<\/h3>\n<p>In the past few months, there\u2019s been a huge increase in Microsoft Teams usage. After the pandemic forced our hand, Teams became the primary tool to facilitate collaboration in many organizations, who often had to speed up their rollout plans and let their employees work from home.<\/p>\n<p>One of the main ways to share information in a Microsoft Teams Channel is to display that information in a Microsoft Teams Tab.<\/p>\n<p>Nanddeep Nachan contributed a command to return information about a specific Microsoft Teams Tab.<\/p>\n<p>To retrieve a Microsoft Teams Tab, execute:<\/p>\n<pre><code class=\"language-sh\">m365 teams tab list --teamName \"Team Name\" --channelName \"Channel Name\" --tabName \"Tab Name\"\n<\/code><\/pre>\n<h3>List installed personal Microsoft Teams apps<\/h3>\n<p>While deploying Teams, many organizations want to go beyond the standard setup and offer their employees a set of additional applications they can use to work more effectively. But managing these applications at scale can quickly become cumbersome. To help organizations discover apps that are being used by employees, S\u00e9bastien Levert contributed a command to list personal apps installed for a specific employee.<\/p>\n<p>To retrieve Microsoft Teams personal apps installed by an employee, execute:<\/p>\n<pre><code class=\"language-sh\">m365 teams user app list --userName admin@contoso.com\n<\/code><\/pre>\n<p>For more information about managing Microsoft Teams using CLI for Microsoft 365, see the docs at <a href=\"https:\/\/aka.ms\/cli-m365\">aka.ms\/cli-m365<\/a>.<\/p>\n<h2>New script samples<\/h2>\n<p>CLI for Microsoft 365 is a great tool both for quick adjustments to the configuration of your Microsoft 365 tenant as well as automating more complex tasks. Because CLI for Microsoft 365 is cross-platform you can use it on any OS and in any shell. To help you get started using the CLI for Microsoft 365 for automation scenarios, we started gathering some sample scripts. Here are the latest additions to the collection.<\/p>\n<h3>Deploy a Microsoft Teams personal app and add it to users<\/h3>\n<p>As many organizations start to leverage the extensibility of Microsoft Teams, they will want to install Microsoft Teams apps for their users, however this is not easily done through the Microsoft Teams admin center.<\/p>\n<p>S\u00e9bastien Levert contributed a sample script that <a href=\"https:\/\/pnp.github.io\/cli-microsoft365\/sample-scripts\/teams\/install-personal-app\/\">deploys a Microsoft Teams app and installs it for specified users<\/a>.<\/p>\n<h3>Uninstall Microsoft Teams personal app from users and remove from Microsoft Teams app catalog<\/h3>\n<p>As many organizations start to leverage the extensibility of Microsoft Teams, they will want to remove Microsoft Teams apps installed by there users and remove that app from the app catalog preventing users from reinstalling, however this is not easily done through the Microsoft Teams admin center.<\/p>\n<p>S\u00e9bastien Levert contributed a sample script that <a href=\"https:\/\/pnp.github.io\/cli-microsoft365\/sample-scripts\/teams\/remove-personal-app\/\">uninstalls a Microsoft Teams app from users and removes it from the Microsoft Teams app catalog<\/a>.<\/p>\n<blockquote><p>If you have any scripts that you use frequently, please <a href=\"https:\/\/github.com\/pnp\/cli-microsoft365\/issues\">share them with us<\/a> so that we can learn more about the common automation scenarios.<\/p><\/blockquote>\n<h2>Contributors<\/h2>\n<p>This release wouldn\u2019t be possible without the help of (in alphabetical order) <a href=\"https:\/\/github.com\/aakashbhardwaj619\">Aakash Bhardwaj<\/a>, <a href=\"https:\/\/github.com\/sebastienlevert\">S\u00e9bastien Levert<\/a>, <a href=\"https:\/\/github.com\/waldekmastykarz\">Waldek Mastykarz<\/a>, <a href=\"https:\/\/github.com\/arjunumenon\">Arjun U Menon<\/a>, <a href=\"https:\/\/github.com\/nanddeepn\">Nanddeep Nachan<\/a>, <a href=\"https:\/\/github.com\/SmitaNachan\">Smita Nachan<\/a>, <a href=\"https:\/\/github.com\/mpowney\">Mark Powney<\/a>, <a href=\"https:\/\/github.com\/appieschot\">Albert-Jan Schot<\/a> and <a href=\"https:\/\/github.com\/garrytrinder\">Garry Trinder<\/a>. Thank you all for the time you chose to spend on the CLI for Microsoft 365 and your help to advance it!<\/p>\n<h2>Work in progress<\/h2>\n<p>Here are some things that we\u2019re 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 CLI for Microsoft 365, 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 CLI for Microsoft 365 each release, we still barely scratched the surface with what\u2019s possible in Microsoft 365. In the upcoming versions of the CLI for Microsoft, you can expect us to add more commands across the different workloads in Microsoft 365.<\/p>\n<h3>Friendlier commands<\/h3>\n<p>Whilst there are now over 350 commands available to use in CLI for Microsoft 365 to help you manage your Microsoft 365 tenant, a lot of commands expect you to provide object ids to perform actions.<\/p>\n<p>We understand that this is not as intuitive as being able to provide a the name of an object and the command work out what the required object ids for you based on the object name given.<\/p>\n<p>We are actively creating new issues to address this, updating our commands to be more user friendly and provide a better user experience.<\/p>\n<p>We&#8217;ll start to implement new <code>name<\/code> options on our Microsoft Teams commands and will start to appear in the next release.<\/p>\n<h3>Quicker and easier developer onboarding<\/h3>\n<p>CLI for Microsoft 365 is a community project and it relies upon contributions from developers around the world to help add new commands and enhance existing commands in every release.<\/p>\n<p>As part of our ongoing improvements to the project, we want to make the onboarding process of new developers to the project as quick and easy as possible.<\/p>\n<p>We will be looking to release a remote development container, that will provide a one click approach for developers to configure a development environment with all dependencies and tools required to contribute to the project.<\/p>\n<p>The release will also support use of GitHub Codespaces, enabling developers to spin up dedicated development environments in the cloud and contribute to the project using nothing but a web browser.<\/p>\n<h3>Run CLI for Microsoft 365 in a Docker container<\/h3>\n<p>The CLI for Microsoft 365 has been designed from the beginning to be platform agnostic, continuing on this theme we will be looking to publish a Docker image to the Docker Hub registry.<\/p>\n<p>This will enable administrators and developer to run an isolated Linux container with the CLI for Microsoft 365 pre-installed and ready to use.<\/p>\n<h3>Script examples<\/h3>\n<p>In every release of the CLI for Microsoft 365, we introduce new commands for managing Microsoft 365. With 360 commands across the different Microsoft 365 services, the CLI for Microsoft 365 has become a powerful tool, not just for managing your tenant but also for automating your daily work.<\/p>\n<p>We\u2019d love to show you how you can use the CLI for Microsoft 365 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.<\/p>\n<h3><code>ensure<\/code> commands<\/h3>\n<p>Currently, CLI for Microsoft 365 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\u2019d need to see if it exists, create it if it doesn\u2019t or update it if it does.<\/p>\n<p>We\u2019re thinking about simplifying this scenario by introducing commands with a new verb named ensure. For example, to ensure that a particular site collection exists, instead of executing a combination of spo site list\/spo site get, spo site add and spo site set, you\u2019d execute spo site ensure with the necessary parameters which would automatically verify if the particular site exists and matches your configuration. If the site doesn\u2019t exist, it would create it. If it does, the command would check if the properties you specified match the retrieved site and update them if necessary.<\/p>\n<p>We\u2019ll start to implement this idea on the spo site commands. We\u2019d love to hear from you if it\u2019s something that you\u2019d 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 set commands in the CLI for Microsoft 365 support only a handful of options that correspond to the properties of their SharePoint class, like Web, Site, List, etc. This is similar to how the Set-PnP* 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 $object.ExecuteQuery() to persist the changes outside of PnP cmdlets. Because the CLI doesn\u2019t use CSOM, this isn\u2019t possible and users are limited to using whatever options are exposed by the CLI commands.<\/p>\n<p>We\u2019re 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 bool, string or int because complex values likely can\u2019t be serialized to string 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 spo web set command with this functionality. We\u2019d love you to try it and tell us what you think.<\/p>\n<h2>Try it today<\/h2>\n<p>Get the latest release of the CLI for Microsoft 365 from npm by executing in the command line:<\/p>\n<pre><code class=\"language-sh\">npm i -g @pnp\/cli-microsoft365\n<\/code><\/pre>\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\/cli-m365\">aka.ms\/cli-m365<\/a>. If you see any room for improvement, please, don\u2019t hesitate to reach out to us either on GitHub or twitter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve just published a new version of CLI for Microsoft 365 with commands for managing Microsoft 365 tenants and SharePoint Framework projects on any platform.<\/p>\n","protected":false},"author":69079,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[],"class_list":["post-5518","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office-add-ins"],"acf":[],"blog_post_summary":"<p>We&#8217;ve just published a new version of CLI for Microsoft 365 with commands for managing Microsoft 365 tenants and SharePoint Framework projects on any platform.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/5518","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=5518"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/5518\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=5518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=5518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=5518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}