mercredi 17 décembre 2014

How do I move a list item to the owner's recycling bin?



I have a need to run a PowerShell script against a list that deletes items older than 15 days. I have the script written, as well as user notifications, however I am puzzled as to how I can recycle the item as the owner of the document.


This is simplified for the sake of the question, but this is the basic operation going on.



$fileage = 15
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'"
$query.RowLimit = 2000;
$query.Query = '<OrderBy><FieldRef Name="Occurred" /></OrderBy><Where><Lt><FieldRef Name="Modified" /><Value Type="DateTime"><Today OffsetDays="-' + $fileAge + '" /></Value></Lt></Where>'
$listItems = $list.GetItems($query)
ForEach($file in $listItems){$item.Recycle()}


Now all the items in that list end up in the recycling bin of the user I ran the command under. Is it possible to take those files and move them into a specific user's bin?








0 commentaires:

Enregistrer un commentaire