SharePoint Online:Powershell从创建的文档集中获取id [英] SharePoint Online : Powershell get id from document set created

查看:129
本文介绍了SharePoint Online:Powershell从创建的文档集中获取id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 


我创建了一个由powershell创建的文档,我想获取文档集的ID以更新具有此ID的名称。其中文档的名称是Name_ID .. 



我无法获取当前文档的ID,它是空的..如何检索当前文档集的ID?


#按名称获取内容类型
  ;   $ ct = $ oList.ContentTypes |其中{$ _.Name -Match" Contract"}
    $ Context.Load($ CT)    
    $ Context.ExecuteQuery()
   



ForEach($ contractcsv合约){
   
           
$ contratcName = $ contract.CONTRACT_NAME;
$ contratcTitle = $ contract.CONTRACT_NAME;

$ ContractDocumentSet = [Microsoft.SharePoint.Client.DocumentSet.DocumentSet] :: Create($ Context,$ oList.RootFolder,$ contratcName,$ ct.Id)
             

$ Context.ExecuteQuery();

       
$ DocSetRelativeUrl = $ SiteURL +" / Contracts /&\"+ $ contratcName
$ CurrentDocSet = $ Context.web.GetFolderByServerRelativeUrl($ DocSetRelativeURL)
$ Context.Load($ CurrentDocSet)
$ Context.ExecuteQuery()
$ DsProperty = $ CurrentDocSet.ListItemAllFields


#Update文档集名称

$ id = $ DsProperty [" ID"];
$ val =" $($ contratcTitle)_ $($ id)" ;;
$ DsProperty [" FileLeafRef"] = $ val;
$ DsProperty.Update();

}

祝你好运, 


Sébastien

解决方案

您好Sébastien,


请修改以下代码。

 


ContractDocumentSet = [Microsoft.SharePoint.Client.DocumentSet.DocumentSet] :: Create(


Context,

Hello, 

I create a document set by powershell and i would like to get ID of the document set create to update name with this ID. where Name of the document is Name_ID.. 

I m not able to get ID of the current document, it is empty.. How to retrieve ID of the current document set?

#Get the content type by its name
    $ct = $oList.ContentTypes | Where {$_.Name -Match "Contract"}
    $Context.Load($ct)    
    $Context.ExecuteQuery()
   



ForEach ($contract in $contractscsv){
   
            
$contratcName = $contract.CONTRACT_NAME;
$contratcTitle = $contract.CONTRACT_NAME;

$ContractDocumentSet = [Microsoft.SharePoint.Client.DocumentSet.DocumentSet]::Create($Context, $oList.RootFolder, $contratcName, $ct.Id)
             

$Context.ExecuteQuery();

        
$DocSetRelativeUrl = $SiteURL+"/Contracts/"+$contratcName
$CurrentDocSet = $Context.web.GetFolderByServerRelativeUrl($DocSetRelativeURL)
$Context.Load($CurrentDocSet)
$Context.ExecuteQuery()
$DsProperty = $CurrentDocSet.ListItemAllFields


#Update Document Set Name

$id= $DsProperty["ID"];
$val="$($contratcTitle)_$($id)";
$DsProperty["FileLeafRef"] = $val;
$DsProperty.Update();

}

Best regards, 

Sébastien

解决方案

Hi Sébastien,

Please modify the code as below.


ContractDocumentSet = [Microsoft.SharePoint.Client.DocumentSet.DocumentSet]::Create(


Context,


这篇关于SharePoint Online:Powershell从创建的文档集中获取id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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