Set-PnPListItem

Tip

We encourage you to make improvements to this documentation. Please navigate to https://github.com/pnp/powershell/blob/dev/documentation/Set-PnPListItem.md to change this file.

Updates a list item

Syntax

Set-PnPListItem
   [-List] <ListPipeBind>
   -Identity <ListItemPipeBind>
   [-ContentType <ContentTypePipeBind>]
   [-Values <Hashtable>]
   [-UpdateType <UpdateType>]
   [-Label <String>]
   [-ClearLabel]
   [-Connection <PnPConnection>]
Set-PnPListItem
   [-List] <ListPipeBind>
   -Identity <ListItemPipeBind>
   -Batch <PnPBatch>
   [-ContentType <ContentTypePipeBind>]
   [-Values <Hashtable>]
   [-UpdateType <UpdateType>
   [-UpdateOverwriteVersion]
   [-Connection <PnPConnection>]

Examples

EXAMPLE 1

Set-PnPListItem -List "Demo List" -Identity 1 -Values @{"Title" = "Test Title"; "Category"="Test Category"}

Sets fields value in the list item with ID 1 in the "Demo List". It sets both the Title and Category fields with the specified values. Notice, use the internal names of fields.

EXAMPLE 2

Set-PnPListItem -List "Demo List" -Identity 1 -ContentType "Company" -Values @{"Title" = "Test Title"; "Category"="Test Category"}

Sets fields value in the list item with ID 1 in the "Demo List". It sets the content type of the item to "Company" and it sets both the Title and Category fields with the specified values. Notice, use the internal names of fields.

EXAMPLE 3

Set-PnPListItem -List "Demo List" -Identity $item -Values @{"Title" = "Test Title"; "Category"="Test Category"}

Sets fields value in the list item which has been retrieved by for instance Get-PnPListItem. It sets the content type of the item to "Company" and it sets both the Title and Category fields with the specified values. Notice, use the internal names of fields.

EXAMPLE 4

Set-PnPListItem -List "Demo List" -Identity 1 -Label "Public"

Sets the retention label in the list item with ID 1 in the "Demo List".

EXAMPLE 5

$batch = New-PnPBatch
for($i=0;$i -lt 100;$i++)
{
    Set-PnPListItem -List "Demo List" -Identity $i -Values @{"Title"="Updated Title"} -Batch $batch
}
Invoke-PnPBatch -Batch $batch

This example updates the items with ids 0 to 100 with a new title in a batched manner.

EXAMPLE 6

Set-PnPListItem -List "Demo List" -Identity 1 -Values @{"Editor"="testuser@domain.com"} -UpdateType UpdateOverwriteVersion

This example updates the modified by value of the list item and does not increase the version number.

Parameters

-Batch

Optional batch object used to add items in a batched manner. See examples on how to use this.

Type:PnPBatch
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ClearLabel

Clears the retention label of the item.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:PnPConnection
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ContentType

Specify either the name, ID or an actual content type

Type:ContentTypePipeBind
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Identity

The ID of the listitem, or actual ListItem object

Type:ListItemPipeBind
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-Label

The name of the retention label.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-List

The ID, Title or Url of the list.

Type:ListPipeBind
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-UpdateOverwriteVersion

Update the item without creating a new version. It will not trigger events registered on the list.

Type:UpdateType
Position:Named
Default value:Update
Accept pipeline input:False
Accept wildcard characters:False
-UpdateType

Specifies the update type to use when updating the listitem. Possible values are "Update", "SystemUpdate", "UpdateOverwriteVersion".

  • Update: Sets field values and creates a new version if versioning is enabled for the list
  • SystemUpdate: Sets field values and does not create a new version. Any events on the list will trigger.
  • UpdateOverwriteVersion: Sets field values and does not create a new version. No events on the list will trigger.
Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Values

Use the internal names of the fields when specifying field names.

Single line of text: -Values @{"TextField" = "Title New"}

Multiple lines of text: -Values @{"MultiTextField" = "New text`n`nMore text"}

Rich text: -Values @{"MultiTextField" = "<strong>New</strong> text"}

Choice: -Values @{"ChoiceField" = "Value 1"}

Number: -Values @{"NumberField" = "10"}

Currency: -Values @{"NumberField" = "10"}

Currency: -Values @{"CurrencyField" = "10"}

Date and Time: -Values @{"DateAndTimeField" = "03/13/2015 14:16"}

Lookup (id of lookup value): -Values @{"LookupField" = "2"}

Multi value lookup (id of lookup values as array 1): -Values @{"MultiLookupField" = "1","2"}

Multi value lookup (id of lookup values as array 2): -Values @{"MultiLookupField" = 1,2}

Multi value lookup (id of lookup values as string): -Values @{"MultiLookupField" = "1,2"}

Yes/No: -Values @{"YesNoField" = $false}

Person/Group (id of user/group in Site User Info List or email of the user, separate multiple values with a comma): -Values @{"PersonField" = "user1@domain.com","21"}

Managed Metadata (single value with path to term): -Values @{"MetadataField" = "CORPORATE|DEPARTMENTS|FINANCE"}

Managed Metadata (single value with id of term): -Values @{"MetadataField" = "fe40a95b-2144-4fa2-b82a-0b3d0299d818"} with Id of term

Managed Metadata (multiple values with paths to terms): -Values @{"MetadataField" = ("CORPORATE|DEPARTMENTS|FINANCE","CORPORATE|DEPARTMENTS|HR")}

Managed Metadata (multiple values with ids of terms): -Values @{"MetadataField" = ("fe40a95b-2144-4fa2-b82a-0b3d0299d818","52d88107-c2a8-4bf0-adfa-04bc2305b593")}

Hyperlink or Picture: -Values @{"HyperlinkField" = "https://pnp.github.com/powershell, PnP PowerShell Home"}

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False