如何使用power shell在文档库中创建共享点2013日期列? [英] How to create the share point 2013 date column in document library using power shell?

查看:57
本文介绍了如何使用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"


这篇关于如何使用power shell在文档库中创建共享点2013日期列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆