Here you go:
Function Do-WhatOPAskedFor
{
param
(
[Microsoft.SharePoint.SPList] $list
)
# Please note that this is a bad way of getting all items from the list!
$items = $list.Items
$items | Align-DateFields "Modified" "Date Last Saved"
}
Function Align-DateFields
{
param
(
[string] $dateModifiedFieldName,
[string] $dateLastSavedFieldName,
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Microsoft.SharePoint.SPListItem] $item
)
begin {}
process
{
[DateTime]$dateLastSaved = $item[$dateLastSavedFieldName];
$item[$dateModifiedFieldName] = $dateLastSaved;
$item.Update();
}
end {}
}
Do-WhatOPAskedFor
will do what you asked for; I'm just bad at naming functions. What it does is takes a SharePoint list, enumerates its items, and sends each item to be processed by a function. The function Align-DateFields
takes a SharePoint list item, extracts what's in the specified field, and saves it to another field.
Let me know if you need any further details!