 All right. Hello everybody. This is Andrew Connell from Voitanos and thank you very much for joining us this webinar today on Introducing and using the office 365 CLI You just jumped one slide So my name is again is Andrew Connell. I'm your host for the webinar today I am the founder behind Voitanos and you can see a couple of things about my bio that you see there on the slide I'm a co-host of a podcast called the Microsoft Cloud Show founder of Voitanos who's putting on this webinar today And join with me today is Waldeck MasterCars. So Waldeck, would you mind introducing yourself? No, no, no, no Hi, everybody. My name is Valid Masthikas. I am office development amp not not nine nine time amp. I blog I am on on Twitter. I work at Rancor where I built software that helps companies get or avoid risks from customizing Share airpoint and office 365 And today I have the pleasure or I will have the pleasure of showing you the office 365 CLI On which AC and I have been working on for a few months now Awesome. Thanks Waldeck. Hey, so the way we're gonna structure this today is I've got a little bit of Introduction that I want to make around the office 365 CLI and then I'm gonna hand it over to Waldeck I'm gonna let Waldeck do most of the demo or I'm gonna let him do all the demo for the CLI today I will answer any questions that you may have during the webinar so if you wouldn't mind posting them to the question-answer panel that we have here in the zoom plant I'll keep an eye on those answer any questions that we have and then at the end we'll wrap it up and come back and if there are any questions we can take verbally we'll do that at the very end but want to be mindful of your time here today we only got 30 minutes that we've set aside for this so let's go ahead and jump into it so if you wouldn't mind jumping a slide for me Waldeck so like we said we're gonna talk about introducing the CLI installing the CLI using it and then any kind of Q&A the installing and using it that's all Waldeck so let's jump into the introduction first here so first the office CL 365 CLI this is a P&P initiative so from the SharePoint P&P group and what I mean by that is that this is not something that is built and run by Microsoft this is run for the community by the community well really I think probably 50% of your dev team here or maybe 60 70% of your dev team is are the ones who are presenting here for you today so this is an effort that Waldeck and I we talked about a lot Waldeck has put really the blood sweat and tears into this I've been a lot of the just kind of the sounding morning and some thoughts and stuff behind it as well in the background but this is really Waldeck's baby what the 365 CLI is is that it it's best to understand it if you kind of understand where what the motivation was originally for it and where the goal at ultimate goal is for it so Waldeck and I are both we live on macOS on our MacBook Pros we don't use Windows and some of the management tasks that we have with Office 365 and SharePoint is all done sorry SharePoint online is all done with PowerShell so things like managing your site collection app catalogs or your configuration around site collection I said site collection of catalogs for around your CDN for Office 365 you have all that stuff is done through PowerShell management either from the PowerShell command list that Microsoft provides in the SharePoint online PowerShell module or through the what's called PMP PowerShell which is the SharePoint PowerShell modules that the PMP group comes up with that adds up additional capabilities. The Office 365 CLI is a node-based app that you will install through NPM and what that does it gives you the ability to manage your SharePoint and Office 365 environment through a command line interface this is again this this command line interface because it's built on node is cross-platform it works on Windows Mac OS Linux everything that you're going to see is available on all the different platforms nothing is platform specific and it's kind of interesting too as wall like sure recently in a PMP call that about half and half of the people that are installing this are on Mac OS and half are on Windows so it works the same way in both environments you choose what you want people say why are you doing this instead of using PowerShell well I mean everyone's got their own preference and how you want to do this stuff but this is really just another option on if you prefer a CLI approach you prefer a clock cross-platform approach this is your option today the PMP group is working though on the side on taking what they've done around PowerShell and making it what's called PowerShell core or to be cross-platform that is still has a lot of work to be done there but hey you get an option it's not saying one is better than the other one it's just you get a couple different options of different ways of skinning the cat you can get more information about it at SharePoint.github.io slash Office 365 CLI all the installation all the documentation everything is up there on the site in fact I gotta get hats off to Waldeck here because this effort is actually speared on a bunch of the other PMP based projects like different controls that we can use in the in the property pane react controls that are from the PMP group as well those guys have actually taken a lesson or taken a tip from the way that the docs have been done on the Office 365 project Office 365 CLI project and they've done the same kind of docs for their projects as well. This runs in an immersive mode so as you'll see really quickly Waldeck's just going to type in a certain command and then now you're inside of like say a 365 prompt and that's where you'll do all your connection and that kind of stuff. If you jump over to the next slide for me real quick Waldeck. Yep so how does this thing work you're going to be logging in using Azure AD so there is nothing that we're doing with authentication you're actually going to be handed off to Azure AD to go log in just like everything else in 365 works and the way that it works behind the behind the scenes is that the the Office 365 CLI uses and prefers to work with REST APIs first so we use the Azure Active Directory REST APIs, the Office 365 REST APIs, the SharePoint online REST APIs. We use all of those as our endpoints. There are cases though when some things are not covered by the REST APIs for instance such as the working with the I think a site collection app catalog is one thing that is not exposed via the REST APIs and management of that. So with that what we do is we use the same CSOM endpoints that the CSOM client library leverages to implement those things. That's what the PowerShell group uses as well. They use the CSOM PowerShell. They use the CSOM end PowerShell to be able to enable things like the site collection of catalogs. We just bypass the CSOM all together and we just use the endpoints themselves which don't think of this as a hack. These are published APIs. Actually Microsoft had to publish them years ago for the European Union so these are all totally legitimate and totally supported. Another thing about this CLI is it works basically in every version of Node that I've tried it on. Every modern version of Node. So you want to go with an LTS version like six or eight. You want to go with even version nine. I use in version nine. Works just fine. Got a little bit of information there about how to get docs, how to get some help on it as well. But I thought it'd be a little more interesting if we actually saw this thing and actually help more of a demo. So you jump over to my next slide there Waldeck. I'm just going to turn it over to you with a little bit of Latin. Oops. Yeah cool. Thanks you. Sure. So with that, as AC said, let's jump into a terminal and actually show you that thing in practice. So here you see I am on NecoS. I am in iTerm. But it would work exactly the same if you would run it on PowerShow Core, PowerShow on Windows, even Command Prompt on Windows. So it works exactly the same way. And the first thing you do, you can actually use it in two ways. So you can use it in an immersive way, meaning if you type Office 365 or O365 for short and launch it, what you will see is that Command Prompt change. So now you have the O365 Command Prompt from CLI. And in here you can type things like help and you will get the overview. You are basically inside CLI. But with that, you don't get the access to your shell anymore. So if you would type LS to get the list of all files, well, that doesn't work because now you are inside CLI. So you work in an immersive mode. But another way to use CLI is to actually use it directly in a shell. So here I can type LS. But here I can also run things like O365 SBO. So with that, I will get a list of all SharePoint online commands available in CLI. So if you run it directly in a shell, you have to prepend each command with O365 so that your shell knows from where to load commands and how to run them. Or you can run it in an immersive mode where you just directly run commands. And we will get back in a bit to talk more about which mode is useful for what. So the first thing that you have to do before you can use CLI is to connect to your tenant or a site. And you do that using, for example, the LS365 SBO connect command. And for that, you would specify the URL. So let me do that. And I practice with that a lot. And now you will know why exactly. So that URL isn't the easiest one, but that's the tenant that I have. And with that, as you will see here, so now we are into the Azure AD device flow prompt. And it's exactly the same flow that you would see if you would use the Azure CLI. So it's the same thing. So basically you go to the browser. Let me grab this link. Do here. Let me paste it here. And in here, I have to paste the code that I got in here. So I grab this code. I paste it here. And now it says continue. So I want to log in. And in here, I pick my account that is already signed in browser. And with that, I have the access to my tenant. So now it's logged in and it's done. And with that, I can check that I'm actually signed in if I run 0365 SBO status. So that shows me that I use this account to sign into this site. So what are some of the interesting things that you can do with CLI? So first thing is that when you get a new tenant, one of the abilities that are turned off by default is TDN. And that's valuable because it allows you to improve performance of the things that you build in SharePoint because it allows you to deliver the files faster to your users. So with that, you can check whether the tenant or whether that's enabled or not by running SBO CDN get. And here you will get true or false, true meaning enabled if you want to see a more user friendly string, you can add the dash dash both switch. And that will show you exactly the whole text. Well, the reason for which here you see that is true. So only the real value without any additional commands is that you can chain these commands into a script. And then you pass the output of one command into another. And if we add it, if we pass all of the output text, well, that would mean that your command to which you pass all of the output has to parse that. So you can run it into mode. You can run it when you work with it interactively, meaning you run the commands by yourself and you don't run a whole script, you can add both switch to get a more user friendly output, if you will. On the other hand, if you run a script, in that case, you want to ensure that the output you get can be passed from one command to another. Another interesting thing is that when you get CDN and when you enable it, well, there are two ways to enable it, right? You can enable it with or origins or without. And when you provision it without origins, meaning origins are the locations in your tenant, to which if you upload the files, these files will be served through the Office 365 C, C, C, C, and C, E, E, E, and EDN. And if you enable your CDN without origins, well, meaning that none of the files will be served. But actually, there is also one more thing that you have to be aware of, right? So let me show you the origins that are available. Right? So you can do that. I run a SPO CDN origin list and CDN follows the convention that we say, like now, now, now. And at the end, there's always a verb, the action that you want to run, like list, add, set, remove. So we always follow the convention across the whole CLI to make it easier for you to use it and actually understand what each command does. So in here, you can see the list of origins that you have set in your tenant. Now, if that last origin wasn't here, your SharePoint framework solutions wouldn't work because your CDN is enabled, but location from which the files are supposed to be served isn't there. So with that, SPFX wouldn't know how to serve it, right? So with that, you have to ensure that when your CDN is enabled, that this origin is always there, right? And if it's not, you can really easily edit by running all three, six, five, SPO CDN origin, origin, add. And here you would say origin are for short or full origin. And here you would say client side assets, period, right? And that would add the origin and it always takes a minute for it to run. Now, another interesting thing in 365 that you have are tenant properties. Think of it as global config strings across a tenant. So to illustrate that, I have here a page in my site and let me add to this a web part. So that's a web part that I've already built, 365, let me add it to the page. And what you see in here is that it says tracking telemetry, not a fake, right? So apparently this web part is able of tracking some stuff, but that hasn't been enabled. And that's exactly how it's being done. It uses for that a tenant property that isn't there. So for that, let me first check which properties are there. So for that, I will run SPO, storage entity. And what you've seen here is that we complete your commands, right? So again, here I will type STO, tab, and with that we complete your input, making it easier for you to work with CLI. And we do this both directly in your shell or in the immersive mode, right? So you can add it up if you use CLI a lot, that's really convenient, right? And here we type list, we provide the URL of the app catalog, which is this one, size apps. And in here, you should now be able to see the list of tenant properties that I have set. Okay, so this is the one, let me add another one to it. So in here, I will say add. I will say property, the key is telemetry, key, and the value is ABC. And it's not add, it's set because you can adjust the value as well. So that was my bad, property is now set. If I go to back to page and refresh the page, we should now see that the web part works. And it's now tracking telemetry using ABC, right? So with CLI, you can actually set up these properties as well. Another interesting thing is if you look at SPFX framework, you can build two things, right? You can build a web part or you can build extension. Now, the great thing about extensions is that they can run on any page across specific site or in your tenant, right? So that allows you to extend UI in a consistent way. After you build them, you have to enable them, right? Unlike a web part that a user adds to a page, extension is being actually enabled by admin. And there are two ways in which it can be done. So first of all, what you can do is you can include a feature in your package. And when you install your package in that site, it will enable that extension in this site. Well, the cool thing about extension is, is that it's like similar to web parts, you can have, you can make them adjustable to size. So you can say, like, for example, imagine you would have extension that shows, that shows weather. You can have it show the weather for one location in one site and another location in another site. But you can only do that if you allow the properties to be set per site. So if you would use the feature to enable extension on your site, well, the same properties would be set on every site because you cannot adjust the feature on the fly. So another way to do it is to actually register the, or to have extension deployed globally across all site in tenant, and then enable it on each specific site with different set of parameters. So for that, let me grab a whole command because that's a tad longer, and I don't want to bore you with typing. So in here, what you see is that I want to add a custom action to this site, site mtest.o10 with title and a name, which is a client site extension of type application customizer. ID is this, and here I include a message, and this one will show on this site. So let me execute that, three to one, let me switch quickly to the site. And if I refresh the page, you will see a message here. Three to one, AC site, excellent. Now let me add the same extension to another site with another message. So let me adjust this one, and this will be my site. And let me deploy it to another site. So that will be 11. Three to one, these things are really quick. And if I here switch to 11, right? So that way you can really easily reuse the same extension across different sites, right? And you can only do that because it's a parameterized. And B, you enable it as custom action on each site setting different parameters, right? So this is how you can do that. We're coming quickly towards the end of the time, and then there are quite a few things that I'd like to show you too. And they are related to using CLI to build scripts, right? So what you've seen so far is that I type commands myself and I execute them, and I basically perform single action. But what if you wanted to use CLI to build scripts? So imagine one script being an admin. Being an admin, imagine that you have a folder like here with a number of .sppkg files that you want to deploy to your farm or tenant, right? So you could do that one by one or you could have a script that will pick all of them and actually add them to your catalog and deploy to your site. And actually that's what we do here, right? We grab all .sppkg files, we run it, and then we add it to catalog. So let me quickly execute that. Let's add to catalog this one here. And then you can see here that we are adding them one by one, adding one, three, two, one, done, there you go, adding another one. And we can directly see the results of that. If I go to the app catalog here, apps for SharePoint, and you can see that they have been added a few seconds ago, a few seconds ago, a few seconds ago, right? So you can see them directly being added here. So with CLI, you can also automate a number of admin tasks, right? And then another thing that I want to do is do, for example, deploy all undeployed apps in your tenant, right? So let me run another script. So here, let me quickly get a list of all apps, so app list. And for that, I also need to specify, do I need to specify that? No, I don't. Yeah. And here you can see that two of the apps that we have are not deployed. So again, for that, we can use CLI to build a script that will get that list and will deploy all not deployed apps, right? So let me quickly run another script and while it runs, let me show it to you on the screen and walk you through it. So what we do here is, first of all, we get the output of, we get all our apps, right? And here, we set the output as JSON string. So if I would run only that in command line, what you will see is exactly that, a string. And the reason for that is, is that we want to pass this output to another command, right? Because we don't want to run all apps. We only want to run on some apps, right? And if you would pass this output, well, meaning you would have to do a string parsing to get out of this table, which is visually appealing to get the data that you need, right? So it's easier to get the JSON string and to parse that. So we pass all of that to a tool named JQ and that tool allows you to parse a JSON string as object, hurry it, iterate over it and all of that. And basically, what we do here is for the whole array, we want to get objects that are not deployed and for each one, we want to have an ID. So that basically gives us array of IDs through which we iterate and then deploy them to a tenant, right? So that's what we do here. So another case of an admin task that you can use to simplify your life managing these apps. And to close it, another really cool thing is that if you build SPFX packages, well, there are, you probably know commands like Gal bundle, Gal package solution, right? To build the project. But then you have a package and then you have to manually drag and drop to your tenant or upload that. So why not automate it? So imagine that you could have one script that says npm run deploy and you enter that and that whole script will bundle the project, package it, deploy it to your catalog or add it to catalog, deploy it to your site. And it will do all of that by itself. So while that runs, let me show you the script. And it seems like a lot, but it's not. So to make it easier for you to read, let me quickly copy that, add it to new window, move it this one. And then here, let's break it line by line. So here we first do the bundling and we make a package, right? Next, we output some additional text that we know what the script does. And then we add the package to catalog. Next, we output some more stuff. And then we get from the catalog ID of the app that we have just added, the package that we have just added. So again, we get the list of all of them. We query them by name and then we get the ID of it. We output some more text and finally deploy it to tenant. So you can do all of that, all of these different steps that you would otherwise have to do manually as a single script, single command, that you can just run. I suspect we have four minutes left. AC, you want to take over, get back to slides, quick questions that would answer? Yeah, absolutely. That was really good. Thank you very much for doing that. I love the scripts part that you were showing at the end, too, where we could see how you could integrate this in your pipeline or in your build pipeline. We did get one question from Rajesh about using scripts. So he's asking if he can use credentials in an SH script instead of using the Azure AD device login option. Is there a way to pass credentials in and have the CLI authenticate for you? Or is this, is that always going to be an interactive thing? So what you can do, so for example, imagine, let me illustrate that if I would run PowerShell Core here, right? So that's a new window and that may increase the form because otherwise you won't be able to see anything. Thank you. There you go, right? So that's a new window that I've opened, right? So I have not been here earlier. That's the first time that I've opened it. It's really long, isn't it? Anyway, so in here, I can type all 365 SPO status. And what you see here is that I am already signed in. So the way we do it is that, for example, when you build a script, you run each command as separate instance of CLI, right? So it starts, runs command and closes. So when you connect to your tenant, we keep that info until it expires A or B, you explicitly say all 365 SPO disconnect. So in other words, in your farm, when you would connect, you can connect once and keep that connection for a long time, right? Because that's based on two things. That's just all of. So we have two bits. We have refresh token, which can be reused to refresh the connection for a long, long time, right? So we can keep that up really long, right? So that would allow you to have the non-interactive usage of CLI. Gotcha, yeah. And I think so that what we're doing here, Rajesh, is that we're also, we're following the same model for the CLI that the Azure CLI does as well. So I mean, we're trying not to, you know, so many times you see these different projects like those even community-based projects, they get spun up and they try and do things a different way than something else. The idea here is that, you know, for, there's a lot of people out there that use Azure, the Azure CLI, instead of using the PowerShell commandlets to be able to administer their Azure, their Azure infrastructure, Azure investments. And we wanted to make sure that we had the same kind of thing. And we don't want to try and do anything that's too different from what the Azure guys are doing. I definitely see the value in being able to, you know, pass in the credentials programmatically in some way, so that you could save yourself from having to do that. But we want to try and stay in the same kind of story that what the Azure guys are doing. So yeah, you would have to first, as Waldeck just explained, authenticate once with the device login. And then once you've done that, you're good to go for a good amount of time until your token expires or you manually log out. So generally you're in pretty good shape there. Waldeck, is there anything else that you'd like to add here as we're coming to a close on our time here? Well, so the one thing that I would add is that for all the info, if you want to know more about CLI, we would encourage you to visit a short link that we have named aka.ms slash o365cli. So with that, we tried to make it as easy as we can for you to keep them in mind and to, you know, to find the right info. So you can go to this page and in there, you will see all the docs help on all commands. We have a user guide that walks you from the install, acquiring it, setup, different options. And we also have linked our repo in which we manage the project, support issues, feature requests where the whole team is active, right? Yep. I would say I would even echo too that what you're going to start seeing as well is that you'll start to see some of the commands of things that you can do at the Office 365 CLI. You'll start to see those showing up inside of the Microsoft official SharePoint documentation. Can I really speak to the SharePoint guys because once we start, you know, get to the full feature coverage with SharePoint and we start adding things to say like Exchange Online or Office 365 or by, you know, hypothetically getting into teams and stuff like that, that eventually we will, you may see like documentation showing up for usage on those sites as well. We do know that the SharePoint team though has said that they're totally cool with us submitting updates. In fact, there's a, I've got a handful of pull requests that are on the docs that are waiting to be merged in showing you how to use the CLI for managing your site collection up catalogs, for doing it with the ALM APIs as well because right now it just shows the PowerShell interface from the PMP PowerShell stuff. So, yeah, you got a lot of good stuff there. There's docs there on the site that Waldeck is showing you, you know, get familiar on how to use the help command inside of the CLI. You can always just type in, you know, Office 365 like Waldeck's doing to help SPO. There's help for everything. You help SPO detail on SharePoint, help SPO app, and then it'll show you even getting more and more detail and then do the first one, app ad. Yeah. So, you can see tons of additional documentation. It's all right there. The docs from the website is all, you know, we make sure that everything is all current. We got really high standards for the project for getting new commands, getting added in. So, you're not going to find stuff that's poorly documented. As two people who are pretty anal-attentive, Waldeck and I definitely don't let that stuff fly by and get in the production releases. So, hey Waldeck, thank you very much for taking the time to do this to us today. For everybody who's on the call and if you didn't get a question answered that comes up later, this webinar was recorded. It will be published on the Voigtanos blog later today or tomorrow. And if you have any additional questions, great place to do that is just go to the blog post where this recording is published and post your question in the comments so that everybody else can benefit from it as well. So, Waldeck, thanks a lot for joining us today. Thank you. And thank you everybody else for joining in. Hope to see you soon.