电源外壳 CSOM 选择复选框

共1个回答, 标签: powershell sharepoint csom

我已经到了互联网的尽头。该资源技术集 _ 和 _ get _ a _ 多选择 _ 领域的许多变化

我运行 O365 Sharepoint, 我有一个多复选框列表或多选的 web 部件。

当我查询现有条目时, 数据将以数组的形式返回。当我将数组发送到此字段时, 它不会选择复选框, 尽管字符串的值是可见的。

Multi-Value  {option1, option2, option3}

multi-select

我不能让这个起作用。它真的不在相同的格式, 我的代码是在

Add-Type -Path 'C:\ServOps\com\SharepointRuntimes\Microsoft.SharePoint.Client.dll'
Add-Type -Path 'C:\ServOps\com\SharepointRuntimes\Microsoft.SharePoint.Client.Runtime.dll'
$url = "https://my.foo.sharepoint"

Function Write-ListItems([Microsoft.SharePoint.Client.ClientContext]$Context, [String]$ListTitle) {
$Context.ExecuteQuery()
#
#    The list must be fetched before ListItemCreationInformation binds to put data
#
$List = $Context.Web.Lists.GetByTitle($ListTitle)

$Context.Load($List)
$Context.ExecuteQuery()


#
#
#
$ListItemCreationInformation = New-Object
Microsoft.SharePoint.Client.ListItemCreationInformation
$NewListItem = $List.AddItem($ListItemCreationInformation)
$NewListItem["Title"] = $TASK
$NewListItem["Approximate_x0020_delivery_x0020"] = $AVERAGE_DELIVERY_TIME_SLA

$NewListItem.Update()
$Context.ExecuteQuery()
}
$context = Get-SPOContext -Url $Url -UserName $UserName -Password $Password
Write-ListItems -Context $context -ListTitle "My Sharepoint"
$context.Dispose()
第1个答案

这是我的测试脚本。

Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")

$url = "https://tenant.sharepoint.com/sites/lee/"
Function Get-SPOContext([string]$Url,[string]$UserName,$Password)
{
    write-host Get-SPOContext
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
    $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $Password) #SecurePassword
    return $Context
}

Function Write-ListItems([Microsoft.SharePoint.Client.ClientContext]$Context, [String]$ListTitle) {
#$Context.ExecuteQuery()

#    The list must be fetched before ListItemCreationInformation binds to put data
#
$List = $Context.Web.Lists.GetByTitle($ListTitle)

$Context.Load($List)
$Context.ExecuteQuery()



#
#
$ListItemCreationInformation = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$NewListItem = $List.AddItem($ListItemCreationInformation)
$NewListItem["Title"] = "Title"
$ChoiceValue = "A","C"
$NewListItem["MyChoices"] = $ChoiceValue

$NewListItem.Update()
$Context.ExecuteQuery()
}

$UserName = "user@tenant.onmicrosoft.com"
$Password = ConvertTo-SecureString "pw" -AsPlainText -Force
$spoContext = Get-SPOContext -Url $Url -UserName $UserName -Password $Password

Write-ListItems -Context $spoContext -ListTitle "MyList"
$spoContext.Dispose()
Write-Host 'done'

相关问题

如何在异步和线程中执行大量 sql 查询 在 PowerShell 中处理大型数组 。PowerShell 中的 NET 跟踪,无需创建。配置文件 电源外壳 CSOM 选择复选框