Forum Discussion
farhan faiz
Mar 02, 2017Copper Contributor
SharePoint Online - Upload document using PowerShell / CSOM with meta data
I am trying to upload document to SharePoint Online along with meta data using PowerShell CSOM $Context = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$Creds = New-Object Mi...
farhan faiz
Mar 02, 2017Copper Contributor
Verified GUID and tried but same issue.
If I try to get reference of list item and update mata data, others columns are populated but not managed matadata column.
This time, I don't have error
$Context = CreateConnection #Retrieve list $DocLibName = 'Documents' $List = $Context.Web.Lists.GetByTitle($DocLibName) $Context.Load($List) $Context.ExecuteQuery() $qry = New-Object Microsoft.SharePoint.Client.CamlQuery $items = $List.GetItems($qry) $Context.Load($items) $Context.ExecuteQuery() foreach($item in $items) { try { $item["ManagedMetaDataColumn"] = "f31984fe-f02b-4354-ac6a-cdaa148c1357" $item["New"] = '12344' $item.Update() $Context.ExecuteQuery() } catch [Exception] { $strException = $_.Exception + $_.ErrorDetails + $_.ScriptStackTrace + $_.ErrorDetails + $_.Exception } }
farhan faiz
Mar 19, 2017Copper Contributor
For other, I resolved this by using PnP - Powershell.
You can use either https://github.com/SharePoint/PnP-PowerShell/blob/master/Documentation/SetPnPListItem.md OR https://github.com/SharePoint/PnP-PowerShell/blob/2.12.1702.0/Documentation/SetPnPTaxonomyFieldValue.md