I hope you guys can help.

I have two lists one named approval and another names pages. The lists have the same items in which have a ID of 'PageID.

I need to update a field from approval list to pages list. The fields name in approvals is first published date, in pages list it is called last published date.

I need to write a script to compare the 'Page ID' of the item and if the last published date field is empty in pages list it should populate the field with the information from first published date in approvals list.

I Hope you guys can help. I have the following script which enables me to handle this information if the fields were both within this list. However the fields are in two separate lists hence the need to match PAGEID field as identifier.

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

#Variables that we are going to use for list editing
$listName = "Approvals"

#Get the SPWeb object and save it to a variable
$web = Get-SPWeb http://discoverydev09/

#Get the SPList object to retrieve the "Demo List"
$list = $web.Lists[$listName]

#Get all items in this list and save them to a variable
$items = $list.items

#Go through all items
foreach($item in $items)
    $user = $item["firstpublisheddate"]
    #Change the value of the "Title" column
    $lastpublisheddate = $item["lastpublisheddate"]

        $item["firstpublisheddate"] = $user
    #Update the item


Any help would be greatly appreciated.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.