1. 在https://www.microsoft.com/en-us/download/details.aspx?id=42038这里下载SharePoint Online Client Components SDK, 然后安装.

 

2. 在https://gallery.technet.microsoft.com/office/SharePoint-Module-for-5ecbbcf0这里下载由外国大神写的SharePoint管理模块, 解压后放到C:\Windows\System32\WindowsPowerShell\v1.0\Modules\mySharePoint文件夹里面, 你也可以在C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1这个文件里面加入import-module命令, 以后每次启动PowerShell这个模块就会自动加载了.

 

3. 开始使用新的命令之前, 必须连上你要操作的SharePoint网站, 命令如下:

Connect-SPOCSOM -Username 'abc@xyz.cn' -Url 'https://company.sharepoint.cn/IT/' 

回车之后会跳出对话框让你输入密码, 但是这就无法进行自动化操作, 于是我修改了SPOMod20160326里面的部分代码:

function Connect-SPOCSOM
{
param (
    [Parameter(Mandatory=$true,Position=1)][string]$Username,
    [Parameter(Mandatory=$true,Position=3)][string]$Url,
    [Parameter(Mandatory=$true,Position=4)][string]$Password
)
$pwd=ConvertTo-SecureString $Password -AsPlainText -Force
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $pwd)
$ctx.ExecuteQuery()  
$global:ctx=$ctx
}

 

4. 获取列表名为contact的内容:

Get-SPOListItems -ListTitle "contact" -IncludeAllProperties $true  | select Title,Chinese_x0020_Name,Mobile

 

相关文章:

  • 2022-12-23
  • 2021-06-16
  • 2021-08-05
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-27
  • 2022-02-04
  • 2022-12-23
  • 2021-06-29
  • 2021-11-15
  • 2021-10-06
  • 2022-12-23
相关资源
相似解决方案