SharePoint命令行界面
sharepointcli的Python项目详细描述
安装
$ pip install sharepointcli
配置
对于一般用途,spo configure
命令是设置sharepointcli的最快方法。
输入此命令时,CLI将提示您输入以下配置:
- SharePoint域
- 用户名
- 密码
spo configure
命令将凭据存储在凭据文件中。
您可以为不同的SharePoint域配置多个凭据。
示例:
凭据的优先级顺序如下:
- 命令行选项
- 环境变量
- 凭据文件
命令行选项
可以使用以下命令行选项覆盖默认配置设置。在
- 在
--用户名<;string>;
指定用户名。在
在 - 在
--密码<;string>;
指定与用户名关联的密码。在
在 - 在
--超时<;string>;
以秒为单位指定超时。在
在
环境变量
环境变量提供了另一种指定凭据的方法,并且可以 对编写脚本很有用。 如果通过在命令行上使用参数指定选项,则 重写环境变量或配置文件中的任何值。在
CLI支持以下环境变量:
- 在
SPO\u凭据文件
指定CLI存储凭据的文件的位置。 默认路径是~/.spo/credentials。在
在 - 在
SPO\u用户名
指定用户名。在
在 - 在
SPO_密码
指定与用户名关联的密码。在
在 - 在
SPO\u超时
以秒为单位指定超时。在
在
凭证文件
CLI将敏感的凭据信息存储在主目录中名为.spo
的目录中名为credentials的文件中。
例如,使用spo configure
生成的文件类似于以下内容:
[example.sharepoint.com]username=user@example.compassword=secret
使用
配置
配置凭据。在
用法
$ spo configure [domain]
cp
正在将本地文件复制到SharePoint。在
用法
$ spo cp <LocalPath> <SharePointUrl> or cp <SharePointUrl> <LocalPath>
示例
以下cp命令将单个文件复制到指定站点:
$ spo cp test.txt 'https://example.sharepoint.com/sites/example/Shared documents/test.txt'upload: test.txt to https://example.sharepoint.com/sites/example/Shared documents/test.txt
从以下命令复制单个SharePoint文件:
$ spo cp 'https://example.sharepoint.com/sites/example/Shared documents/test.txt' test.txt download: https://example.sharepoint.com/sites/example/Shared documents/test.txt' to test.txt
帮助
显示命令帮助。在
用法
$ spo help[topic]
ls
列出文件和文件夹。在
用法
$ spo ls [options] <SharePointUrl>
选项
-mtime n文件的状态上次更改是在24小时前。('+n'大于n,'n'正好是n,'-n'小于n)
示例
$ spo ls 'https://example.sharepoint.com/sites/example/Shared documents/*.txt'
mkdir
创建文件夹。在
用法
$ spo mkdir <SharePointUrl>
rm
删除文件。在
用法
$ spo rm [options] <SharePointUrl>
选项
-mtime n文件的状态上次更改是在24小时前。('+n'大于n,'n'正好是n,'-n'小于n)
示例
$ spo rm 'https://example.sharepoint.com/sites/example/Shared documents/*.txt'
rmdir
删除文件夹。在
用法
$ spo rmdir <SharePointUrl>
版本
打印版本号。在
用法
$ spo version
测试
要运行单元测试:
- 创建~/.spo/credentials凭据文件
- 将SharePoint测试站点url导出为环境变量“site”
$ spo configure SharePoint domain (e.g. example.sharepoint.com): example.sharepoint.comUsername: test@example.comPassword: *****$ expot SITE='https://example.sharepoint.com/sites/example/Shared documents/test folder'$ make test
许可证
这个项目是由麻省理工学院授权的。在
链接
- 项目
标签: