Loading...

Silently Update SharePoint Metadata with PnP PowerShell

Silently Update SharePoint Metadata with PnP PowerShell
Featured image of post Silently Update SharePoint Metadata with PnP PowerShell

Why Bother with Metadata?

Think of metadata as the DNA of your SharePoint content. It tells you who created a document, when it was last touched, and more. This information isn’t just for kicks; it’s vital for audits, compliance, and knowing the lineage of your content.

Keeping Metadata Intact with Updates

Sometimes you need to adjust a document’s details but want to keep the original ‘Modified By’ data. PnP PowerShell is your ally here:

1
2
3
4
5
6
7
# Connect to your SharePoint site
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/demo -Interactive

# Preserve metadata with a SystemUpdate
Set-PnPListItem -List "Tasks" -Identity $item -Values @{
    "Title"="New Project Title"
    } -UpdateType SystemUpdate

Understanding Update Types in PnP PowerShell

When you’re updating SharePoint items with PnP PowerShell, you have three update methods at your disposal, each serving a different purpose. Let’s demystify these:

  1. Update

    This is the standard update command. When you use Update, SharePoint treats the action as if you manually updated the item through the UI. This means:

    The “Modified” and “Modified By” fields will be updated to reflect the time of the update and the user who made the change. If versioning is enabled on the list or library, a new version will be created. Use it when you want to make a straightforward update that logs your changes as a new version.

  2. SystemUpdate

    SystemUpdate is more discreet:

    It updates items without changing the “Modified By” and “Modified” fields. A new version is created if versioning is enabled, but it will not show as a new “modified” entry. This method is perfect when you need to make changes that don’t affect the item’s version history as seen by end-users, like during system migrations or bulk updates.

  3. UpdateOverwriteVersion

    The UpdateOverwriteVersion is the stealth operator:

    It updates the item while keeping the “Modified By” and “Modified” fields as they were. It does not create a new version; instead, it overwrites the current version, even if versioning is enabled. This approach is suitable when you want to make a correction to the current version of an item or document without increasing the version count, effectively keeping the update under the radar.

Changing Creator and Creation Dates: Is It Even Possible?

Yes, it is! Adjusting the creator or creation date of a document is sometimes necessary, such as during migrations or clean-ups. Here’s how you can accomplish this:

1
2
3
4
5
6
7
8
9
# Fetch the item you need to update
$item = Get-PnPListItem -List "Documents" -Id 42

# Change the "Created By" and "Created" fields
$creationDate = Get-Date "2020-01-14"
Set-PnPListItem -List "Documents" -Identity $item -Values @{
    "Author" = $newCreatorUserId;
    "Created" = $creationDate
} -SystemUpdate

Data Integrity Best Practices

To safeguard your SharePoint content during updates, here are some best practices to uphold data integrity:

  • Maintain a Change Log: Documenting changes ensures accountability and traceability.
  • Secure Approvals: Validate that all updates are authorized and documented.
  • Test Before Implementing: Always preview changes in a safe environment to prevent unintended consequences in your live content.

Conclusion

With PnP PowerShell, you have the tools to adjust metadata with precision, ensuring that your SharePoint data tells its true story without unintended revisions. It’s about strategic changes that respect the narrative of your data.

Further Reading

Delve deeper into PnP PowerShell with the official cmdlet documentation for Set-PnPListItem, available here.

Published on:

Learn more
Need help with this product?

We can help you with Silently Update SharePoint Metadata with PnP PowerShell

If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.

The State of the Microsoft 365 Nation
The State of the Microsoft 365 Nation

Recent content on The State of the Microsoft 365 Nation

Share post:

Related posts

Creating Copilot Studio Agents Without an M365 Copilot Premium License

A common assumption when getting started with Copilot Studio is that you need a full Microsoft 365 Copilot Premium license. That assumption is...

6 months ago

Power Automate: Get events (V4) shared mailbox fix

When your flow reads a shared mailbox calendar using the Office 365 Outlook → Get events (V4) connector, it can fail in a way that looks like...

8 months ago

Using Managed Identity with Azure Automation & PnP.PowerShell

How to Set Up a Managed Identity for Azure Automation Runbooks and Use It in PowerShell Scripts with PnP.PowerShell This guide walks you throu...

1 year ago

UPDATED - Set Up Pay-as-you-go M365 Chat & SharePoint Agents

Introduction to Pay-as-You-Go Agents in Microsoft 365 Microsoft has introduced a flexible way for organizations to leverage AI capabilities wi...

1 year ago

How to Use Flexible Sections in SharePoint Pages and News

If you’ve been using SharePoint Online to build pages or share news, you know how important it is to have a layout that works for your c...

1 year ago

What's New in SharePoint Pages

1. New Carousel Layout in the Hero Web Part The Hero Web Part has always been a fundamental element of SharePoint pages. The new Carousel Layo...

1 year ago

Power Platform Solutions Made Simple

Introduction to Power Platform Solutions Power Platform Solutions offer many benefits, especially when moving from standalone flows and apps t...

1 year ago

Use your Bluesky post for comments on your Hugo Blog

Since Bluesky is getting really popular by people I interact with, I decided to switch my blog comments to Bluesky posts. In this blog post, I...

1 year ago

Exploring SharePoint Online's SiteAssets Library

The SiteAssets library in SharePoint Online often seems like a mystery to a lot of users I talk to, but it’s important to understand it ...

1 year ago

Step-by-Step Guide to Copy Pages between SharePoint Online

Unfortunately you can’t copy pages in SharePoint through the UI. But sometimes you may need to copy pages and their associated SiteAsset...

1 year ago

Newsletter

Get the latest Dynamics 365 and Power Platform content in your inbox

A curated digest of community blogs, product news, videos, and podcasts — delivered without the noise.

Weekly updates Unsubscribe anytime Fresh community picks
We use your email only for the newsletter and you can unsubscribe at any time.
By subscribing, you agree to the privacy policy.