2

I have a series of content types created in the content type gallery of the SharePoint admin center. I am trying to apply metadata in bulk using PowerShell to columns inherited from those content types.

When I attempt to use Set-PnPListItem it tells me the column doesn't exist and may have been deleted by another user. Similar issues raised here and on other forums were solved by using the actual name (from the column URL) for the column instead of the display name. The URL shows this for the column name Effective%5Fx0020%5FDate. That and the regular version "Effective Date" do not work.

I can set values of other columns which were not inherited from content types, but anything from a content type is not working for me.

I want to know if these types of columns need a workaround or a change to the standard syntax.

This Works:

Set-PnPListItem -List "Shared Documents" -Identity 237519 -ContentType "Contract" -Values @{"SortingIndex"= 8675309}

This doesn't:

Set-PnPListItem -List "Shared Documents" -Identity 237519 -ContentType "Contract" -Values @{"Effective Date"= [DateTime]"2020-7-16"}
4
  • This doesn't work either Set-PnPListItem -List "Shared Documents" -Identity 237519 -ContentType "Contract" -Values @{"EffectiveDate"= [DateTime]"2020-7-16"} Commented Aug 2, 2022 at 1:19
  • Try this column name: Effective_x0020_Date. Let me know if it works. Commented Aug 2, 2022 at 3:46
  • @GaneshSanap That worked! We were able to find the column names formatted that way from the console output generated by object.FieldValues The %Fx is an underscore.... I should have realized. Commented Aug 2, 2022 at 22:41
  • 1
    Great, glad it worked for you! Commented Aug 3, 2022 at 5:03

1 Answer 1

1

You have to use the internal name of column in PnP PowerShell while updating the value. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

Generally, when you create a column with <space> in between, <space> gets converted to _x0020_ in SharePoint.

So, for "Effective Date" display name, internal name should be like: Effective_x0020_Date.

The one which you are trying (Effective%5Fx0020%5FDate) is URL encoded name. You have to decode it which should also result to: Effective_x0020_Date.


So, try using Effective_x0020_Date and it should work for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.