|Microsoft Office 365 CLI command completion||Gustavo Velez|
|After installing the Microsoft 365 CLI, all the commands can be used, but "command completion", the option to complete a partially typed command using the tab key, is not available||07-12-2020|
The Microsoft 365 CLI (Common Line Interface) allows working with a command-line tool from different Operating Systems (Windows, Linux, MacOS), without needing to switch from PowerShell to Bash, to Cmder, or to whatever shell you use.
After the CLI is installed in the developer or administrator computer, all the commands are ready to be used, but you cannot complete a partially typed command with the tab key, as usually when using PowerShell in Windows.
To enable completion in your current PowerShell profile, Start PowerShell, and execute the command:
m365 cli completion pwsh setup --profile $profile
This will generate a commands.json file in the folder where the CLI for Microsoft 365 is installed, normally C:\Users\gavd\AppData\Roaming\npm\node_modules\@pnp\office365-cli, containing all available commands and their options, and register completion in the PowerShell profile
After restarting PowerShell, you should now be able to complete commands using the tab key. For example, typing m365 s[tab] will complete it to m365 spo, and typing m365 spo [tab][tab] will list all SharePoint Online commands available in CLI for Microsoft 365.
Because the commands.json file does not update automatically when a recent version of the CLI is installed, run the following command after installation of each update:
m365 cli completion pwsh update
To disable CLI for Microsoft 365 command completion, open the PowerShell profile file in an ASCII text editor, and remove the reference to the Register-O365CLICompletion.ps1 script, and restart PowerShell. PowerShell can have different profile files; to find the location of the files, run the command:
$PROFILE | Get-Member -Type NoteProperty | Format-List *