Powershell Sharepoint Online-将内容类型添加到列表

Powershell Sharepoint Online-将内容类型添加到列表,powershell,sharepoint,sharepoint-online,Powershell,Sharepoint,Sharepoint Online,我正在尝试向Sharepoint Online中的文档库添加内容类型。 下面的代码运行时没有错误,但内容类型没有添加到文档库中 有什么想法吗 谢谢 P 似乎我错过了这部分 $context.ExecuteQuery() 您是否应该执行$addContentType=$list.ContentTypes.Add($newCT)$list.Update()而不是尝试查找现有的contenttype?谢谢@Theo我尝试了,但还是一样。代码已运行,但未将内容类型添加到文档库。很抱歉,

我正在尝试向Sharepoint Online中的文档库添加内容类型。 下面的代码运行时没有错误,但内容类型没有添加到文档库中

有什么想法吗

谢谢 P


似乎我错过了这部分

        $context.ExecuteQuery()

您是否应该执行
$addContentType=$list.ContentTypes.Add($newCT)$list.Update()
而不是尝试查找现有的contenttype?谢谢@Theo我尝试了,但还是一样。代码已运行,但未将内容类型添加到文档库。很抱歉,我收到一个错误。。。无法将值为“Microsoft.SharePoint.Client.ContentType”的参数“parameters”转换为“Microsoft.SharePoint.Client.ContentTypeCreationInformation”:“无法将类型为“Microsoft.SharePoint.Client.ContentType”的“Microsoft.SharePoint.Client.ContentType”值转换为类型”Microsoft.SharePoint.Client.ContentTypeCreationInformation.“``write host”列表名为“$List.Title write host”列表名为“$List.Id write host”ContentType为“$ContentType.name”请尝试{$AddContentType=$List.ContentTypes.Add($ContentType)}捕获{write host”错误!\write host我从不喜欢Sharepoint。。问题是,我没有看到您的代码调用$list上的
.Update()
方法。如果你只是把它添加到代码中呢?
        $context.ExecuteQuery()