# Get the SharePoint Assembly
# You will need to run this on the SharePoint Server
[Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")
# The site my list was in was at http://dev
# create a new object called $SPSite
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://dev/")
# Make sure you have the last “/” in the url on the site
# allow $SPWeb to be the OpenWeb from the site
$SPWeb = $SPSite.OpenWeb()
# Get the list ModifyCreatedBy
$SPList = $SPWeb.Lists["ModifyCreatedBy"]
# Get the Collection of the List Items
$SPListItemCollection = $SPList.Items
# iterate the Collection
foreach ($ListItem in $SPListItemCollection)
{
# The user in this case was Test R. Test and had a user id of 8 from the SPWeb users
#
$SPFieldUserValue = New-Object Microsoft.SharePoint.SPFieldUserValue($SPWeb,8, "#Test R. Test")
$ListItem["Author"] = $SPFieldUserValue
# Note: Editor will be the account that you are running the Powershell under unless you update # Editor as well
$ListItem.Update()
}
$SPWeb.Update()
# Still TODO Disposes, Error Checking, Change to take Parameters, etc
Comments
Post a Comment