Quantcast
Channel: SharePoint Legacy Versions - Using SharePoint Designer, InfoPath and Other Customizations Forum
Viewing all articles
Browse latest Browse all 2319

edit created by column using power shell

$
0
0

I wrote the following script to update the created by column of the documents in one of my document libraries:



Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
$SPWeb = Get-SPWeb "";
$SPList = $SPWeb.Lists[""]
$userName = "";
$user = Get-SPUser -web $SPWeb -Identity $userName;
$userString = "{0};#{1}" -f $user.ID, $user.UserLogin.Tostring()
$SPListItemCollection = $SPList.Items

foreach ($ListItem in $SPListItemCollection)

{

$ListItem["Author"] = $userString;
$ListItem.UpdateOverwriteVersion()
}

The script runs successfully but when viewing the metadata from the browser I noticed the values don't get updated

Any ideas ?


Viewing all articles
Browse latest Browse all 2319

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>