Office 365 cli - 像使用powershell操作SharePoint一样操作Office 365 (SharePoint Online, Teams, SFPx...)
Office 365 CLI是微软PnP社区开发的针对Office 365的命令行接口(Command Line Interface)。可以使用这个工具方便地管理Office 365,SharePoint Online以及SharePoint Framework解决方案。这个工具是跨平台的,可以运行在不同的操作系统上,并且是开源的。
这里主要介绍如何使用Office 365 cli管理SharePoint Online和SharePoint Framework解决方案。
1, 安装Office 365 cli, 登陆Office 365
使用npm或者yarn全局安装 ofice 365 cli:
[code]npm i -g @pnp/office365-cli 或者: yarn global add @pnp/office365-cli
安装结束之后可以在命令行工具中(这里使用powershell)运行office365(或者简写o365)命令,打开office 365 cli:
使用version 命令查看当前安装的office 365 cli版本,使用quit命令退出:
如果需要操作SharePoint Online,首先要做的是登陆,登陆命令是 spo login
[code]spo login https://contoso.sharepoint.com/sites/team
执行登陆命令之后,会提示代码浏览器,输入一个验证码:
根据提示打开页面https://microsoft.com/devicelogin,输入登陆验证码:
确认赋予权限:
登陆成功之后,就可以管理Office 365了
退出登录命令:spo logout
2,几个基本命令
a. 查看当前连接状态,显示连接用户和连接站点
[code]spo status
运行结果:
b. 帮助命令help,列出几组命令:
如果查看spo组的命令,使用help spo:
依次类推,如果查看关于site的命令,执行help spo site,会列出关于site 操作的9个命令:
列出某个命令的具体用法:
c.创建一个modern team站点:
[code]spo site add --alias o365clidemo --title "Office 365 CLI Demo"
运行结果:
d. 获取站点信息:
[code]spo site get --url https://contoso.sharepoint.com/sites/o365clidemo
e. 创建一个列表:
[code]spo list add --title 'DemoList' --baseTemplate Announcements --webUrl https://yangsancheng.sharepoint.com/sites/o365clidemo
f. 列出Office 365中安装的所有App:
[code]spo app list
还可以指定以json的格式输出命令执行结果:
[code]spo app list -o json
所有命令的详细介绍请参见这里
3, 创建Team
可以使用Cli在Teams中创建一个Team,这是用Graph命令做到的,首先需要登陆Graph:
登陆成功之后,使用graph status命令查看状态,已经连接成功:
然后使用如下命令创建team:
[code]graph teams add --name 'CliDemoTeam' --description 'Cli Demo Team'
4, 添加和部署SharePoint Framework解决方案包
向App Catalog中添加一个.sppkg包:
[code]spo app add --filePath /pnp/spfx/sharepoint/solution/spfx.sppkg
全局部署一个解决方案:
[code]spo app deploy --id 058140e3-0e37-44fc-a1d3-79c487d371a3 --skipFeatureDeployment
- Office 365 - Windows PowerShell for SharePoint Online
- 使用SharePoint Management PowerShell来完成对SharePoint的操作
- Office 365 用户指引 12 ——SharePoint Online-Overview
- Office 365 用户指引 16 ——SharePoint Online-文档协作
- Office 365 – SharePoint Online allows you to use your mobile device to
- Office 365 用户指引 14 ——SharePoint Online-Onedrive for Business
- Office 365 利用并行工作流构建威客式任务管理系统之使用SharePoint Designer 定制任务过期提醒!
- Office 365 利用并行工作流构建威客式任务管理系统之使用SharePoint Designer 定制威客任务管理流程!
- Office 365 - SharePoint 2013 Online 中使用Windows PowerShell
- Office 365 用户指引 15 ——SharePoint Online-Office Web App
- Office 365 用户指引 13 ——SharePoint Online-新闻源
- Office 365系列六 ------ 创建sharepoint online网站
- Office 365 IT Professional——RMS与SharePoint Online集成管理
- SharePoint 2013 使用JQuery 一些记录如(SharePoint js 获得当前用户)等基本操作。
- Office 365管理员指引 10 ——SharePoint Online 介绍
- 在SQL Server 集成服务中使用开源SharePoint List组件对SharePoint列表进行ETL操作!
- Office 365 plans, SharePoint Online, and SharePoint 2013 on-premises 功能对比列表
- Office 365 plans, SharePoint Online, and SharePoint 2013 on-premises 功能对比列表
- Office 365 SharePoint Online 学习链接
- 如何试用Office 365 及 SharePoint Online(美版)