Handle the Microsoft productiveness cloud out of your keyboard.
Administering Microsoft 365 may be advanced. A lot of what you could do may be achieved via its internet portal, however there are occasions once you want one thing extra interactive, utilizing scripts and different instruments to construct repeatable actions. That’s what the command-line interface for Microsoft 365 is, a software that helps you handle Microsoft 365 tenants from the command line, and which can be utilized programmatically from PowerShell, bash or your individual alternative of scripting setting.
The CLI for Microsoft 365 has been developed by the Microsoft 365 Platform Neighborhood, PnP. Run by each Microsoft workers and Microsoft 365 MVPs, the neighborhood was set as much as share greatest practices and instruments designed to assist them.
SEE: Hiring equipment: Again-end Developer (TechRepublic Premium)
Delivering a software that brings a lot of Microsoft 365 administration into the command line suits nicely with their ethos of not reinventing the wheel, as Microsoft 365 makes it straightforward to share scripts and queries that may assist different admins clear up their issues.
Getting began with the CLI for Microsoft 365
Whereas most admins are more likely to run the CLI from PowerShell on Home windows, it’s constructed as a node.js JavaScript software and may be put in on Linux or macOS, working with any supported shell that may name native functions.
Set up is by way of npm, utilizing it to handle updates and obtain beta take a look at variations. It’s additionally accessible in a Linux Docker container, able to run wherever you have got container assist. There’s an attention-grabbing prospect right here of utilizing the CLI as the inspiration of your individual administration UI for Microsoft 365, utilizing JavaScript to name CLI instructions and parse the JSON outcomes.
It’s vital to recollect to test for updates frequently utilizing npm’s instruments. The workforce provides new options with every launch because the Microsoft 365 API floor grows. Should you don’t want to make use of it anymore, one other npm name will uninstall the CLI.
The primary time you run the CLI, use the m365 login command to authenticate towards your tenant. This can take you thru a web-based authorization process that units the permissions wanted to handle Microsoft 365 remotely. When you settle for the lengthy record of required permissions, you’ll be dropped again into your Home windows Terminal able to go. Alternatively, you’ll be able to log in with a username and password when interactive login isn’t an choice.
Different options assist utilizing Azure Lively Listing secrets and techniques, a helpful choice when constructing the CLI into your individual scripts, although this at present received’t work for any scripts that have to work towards SharePoint On-line’s APIs.
Scripting Microsoft 365
As soon as arrange, you can begin to handle your Microsoft 365 occasion. There are instructions for working at completely different ranges throughout the Microsoft 365 stack, from managing tenant settings to working with particular apps like OneDrive and Groups.
You should use the CLI for Microsoft 365 to gather info that helps you handle your functions and customers. What’s maybe extra helpful is the power to construct advanced scripts round these queries, taking in parameters from one response and utilizing them as inputs into one other. So you will get a listing of all present OneDrive shops, then use that to question how they’re utilizing your storage finances. You may even automate emailing that end result to the suitable managers.
Whereas there are instructions for many Microsoft 365 functions and companies, it’s not stunning that many of the instructions within the CLI are for working with SharePoint On-line. SharePoint stays an vital a part of the suite and a key software for collaboration and communication in lots of organizations. With over 260 instructions centered on managing SharePoint, it’s an important software for any SharePoint admin. With the ability to work with SharePoint programmatically is an enormous time saver, and the rising library of instructions within the CLI cowl a lot of what you could do.
There’s over 60 instructions devoted to working with Groups. You possibly can dynamically handle apps, customers and channels whereas additionally having the ability to automate sending messages to a chat or take information from a script and embed it in an adaptive card for fast interactions. It’s doable to think about a fundamental chatbot calling a CLI script and returning requested information, permitting you to handle your Microsoft 365 tenants with out leaving a gathering or from inside an ongoing workforce chat.
Filtering and utilizing question outcomes
Instructions that return information default to utilizing the JSON format. That is fantastic should you’re constructing CLI instructions into scripts and wish to use PowerShell’s JSON tooling to format outputs. Nonetheless, should you’re making a fast question, it’s not significantly human readable, so you have got the choice of selecting textual content or CSV outputs. The final choice is an effective one to decide on should you’re getting information for a big property of, say, mailboxes, and also you wish to import information into Excel for additional analyses or studies. CSV outputs will mean you can feed information into instruments like Energy BI to run dashboards and different visualizations.
You’re in a position to filter output too through the use of queries to extract the information you need. The question language used is predicated on the JMESPath JSON software and owes loads to acquainted common expression instruments. Usefully, there’s a take a look at software on the JMESPath website that may assist you to format the question you could use to get the information you need. In addition to filtering information, you’re in a position to type and order it, serving to convey related outcomes to the highest of a response with out having to write down your individual sorting capabilities.
Should you’re not fairly positive what command to make use of, there’s assist for command completion utilizing the Clink tooling for many command-line environments. Alternatively, a single line of PowerShell will add command completion for PowerShell’s personal terminal.
Internet-based administration portals like Microsoft 365’s are a useful gizmo, however if you wish to do greater than apply fundamental settings to customers or configure functions, then a command line software like this makes much more sense, particularly when you should use it to programmatically handle your tenants and customers. With cross platform assist, it’s a software that goes the place you might be, guaranteeing that it doesn’t get in your means and suits together with your toolchain and workflow. The result’s an important software for anybody who has to handle Microsoft 365 and SharePoint On-line.