如何使用power shell在文档库中创建共享点2013日期列?
问题描述:
如何使用电源外壳在文档库中创建共享点2013日期列?
请帮助我
问候,
我的尝试:
i尝试了以下两个脚本,下面的脚本仅用于列表,当我执行下面的脚本时,我得到空引用异常。
how to create the share point 2013 date column in document library using power shell?
kindly help me
Regards,
What I have tried:
i tried the below two scripts , below script is working for list only , when i execute the below script i am getting the null reference exception.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebURL="http://portal.crescent.com/sites/Sales"
$ListName="Vendors"
$FieldName="Date of Contract"
$RequiredField=$false
#Get Objects
$Web = Get-SPWeb $WebURL
$List= $Web.Lists[$ListName]
$List.Fields.Add($FieldName,"DateTime", $RequiredField)
或
or
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebURL="http://portal.crescent.com/sites/Sales"
$sList = $WebURL.GetList($listURL)
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Datetime
$sList.Fields.Add("OpCo",$spFieldType,$true)
$field = $sList.Fields["OpCo"]
$field.DefaultValue = $slist.Title
$field.Update()
$sList.Update()
答
WebURL = http://portal.crescent .com / sites / Sales
WebURL="http://portal.crescent.com/sites/Sales"
ListName = 供应商
ListName="Vendors"
FieldName = 合同日期
FieldName="Date of Contract"