PowerShell创建网站栏

SharePoint PowerShell 创建网站栏
最近,有这么个需求,需要使用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和其他对象一些简单的语法区别即可。
共
289
次浏览