通过Powershell v3将列添加到SharePoint Online 2013列表
有人能告诉我怎么做吗?我发现的例子似乎都不起作用 我的站点是,我的列表叫做“pfa”。我想添加一些文本列 我确实通过Powershell与SharePoint Online建立了连接,因为我已设法从各种命令中获得一些结果通过Powershell v3将列添加到SharePoint Online 2013列表,sharepoint,sharepoint-2013,powershell-3.0,sharepoint-object-model,Sharepoint,Sharepoint 2013,Powershell 3.0,Sharepoint Object Model,有人能告诉我怎么做吗?我发现的例子似乎都不起作用 我的站点是,我的列表叫做“pfa”。我想添加一些文本列 我确实通过Powershell与SharePoint Online建立了连接,因为我已设法从各种命令中获得一些结果 谢谢。这里有人通过PowerShell和SharePoint Oneline使用CSOM创建了一个列表 SharePoint online的PowerShell功能仅限于一些基本的管理任务。当您在PowerShell中使用CSOM时,您可以做更多的工作。如何通过PowerShe
谢谢。这里有人通过PowerShell和SharePoint Oneline使用CSOM创建了一个列表 SharePoint online的PowerShell功能仅限于一些基本的管理任务。当您在PowerShell中使用CSOM时,您可以做更多的工作。如何通过PowerShell中的CSOM在SharePoint Online中设置字段 CSOM API随附:
- -向字段中添加字段 收藏
- -根据创建字段 指定的架构、布尔值和字段选项
地理位置
字段添加到联系人
列表中:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime")
function Provision-Field([Microsoft.SharePoint.Client.ClientContext]$Context,[string]$ListTitle,[string]$FieldSchema)
{
$list = $Context.Web.Lists.GetByTitle($ListTitle)
$List.Fields.AddFieldAsXml($FieldSchema,$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView)
$Context.Load($List)
$Context.ExecuteQuery()
}
$UserName = "username@contoso.onmicrosoft.com"
$Password = Read-Host -Prompt "Please enter your password" -AsSecureString
$URL = "https://contoso.sharepoint.com/"
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($URL)
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,$Password)
$Context.Credentials = $Credentials
Provision-Field $Context "Contacts" "<Field Type='Geolocation' DisplayName='Location'/>"
工具书类
http://<site url>/_api/web/fields('<field id>')
http://<site url>/_api/web/lists(guid'<list id>')/fields('<field id>')
Function Add-SPOField(){
Param(
[Parameter(Mandatory=$True)]
[String]$WebUrl,
[Parameter(Mandatory=$True)]
[String]$UserName,
[Parameter(Mandatory=$False)]
[String]$Password,
[Parameter(Mandatory=$True)]
[String]$ListTitle,
[Parameter(Mandatory=$True)]
[String]$FieldTitle,
[Parameter(Mandatory=$True)]
[System.Int32]$FieldType
)
$fieldMetadata = @{
__metadata = @{'type' = 'SP.Field' };
Title = $FieldTitle;
FieldTypeKind = $FieldType;
} | ConvertTo-Json
$Url = $WebUrl + "_api/web/Lists/GetByTitle('" + $ListTitle + "')/fields"
$contextInfo = Get-SPOContextInfo $WebUrl $UserName $Password
Invoke-RestSPO $Url Post $UserName $Password $fieldMetadata $contextInfo.GetContextWebInformation.FormDigestValue
}
. ".\Invoke-RestSPO.ps1" #InInvoke-RestSPO function
$UserName = "username@contoso.onmicrosoft.com"
$Password = Read-Host -Prompt "Please enter your password"
$WebUrl = "https://contoso.sharepoint.com/"
Add-SPOField -WebUrl $WebUrl -UserName $UserName -Password $Password -ListTitle "Documents" -FieldTitle "Comments" -FieldType 3