首页 > 其他专区 > SharePoint >

SharePoint PowerShell 创建网站栏

SharePoint 2021-06-25 20:50:54

最近,有这么个需求,需要使用PowerShell为网站集创建网站栏,好吧,直接看代码吧。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$webUrl = "HTTP://SITEURL"
$listname = "LISTNAME"
$fieldname = "FIELDNAME"
$IsRequired = $False
$FieldType = [Microsoft.SharePoint.SPFieldType]::Text

$site = Get-SPSite $webUrl
$Web = $site.OpenWeb()
$list = $web.Lists.TryGetList($listname)
$field = $list.Fields[$fieldname];

if($field -eq $null)
{
$list.Fields.Add($fieldname,$FieldType,$IsRequired)
$list.Update()
Write-Host $fieldname "is created"
}
else
{
Write-Host $fieldname "is already exist"
}

复制代码

  结束语

  其实,整个代码逻辑和SharePoint其他对象很相似,只要掌握PowerShell和其他对象一些简单的语法区别即可。



标签: PowerShell创建网站栏

[免责声明]本文来源于网络,不代表本站立场,如转载内容涉及版权等问题,请联系邮箱:83115484#qq.com,#换成@即可,我们会予以删除相关文章,保证您的权利。转载请注明出处:http://www.tutorialesandroide.com/wps/sharepoint/460.html

飞兔问答 Copyright © 2016-2021 www.tutorialesandroide.com. Some Rights Reserved. 备案号:渝ICP备2023004149号-43

本站非盈利性质,内容来源于互联网,如有冒犯请联系我们立删邮箱:83115484#qq.com,#换成@就是邮箱 网站地图