PowerShell script to move items to record center. If I use the ‘Copy’ option, all of the files are copied to the record center but when I use the ‘Move’ option, it only moves half of the files. I can run it multiple times but it always only moves half.
$ additionalInfo = "" $ tgtUri = [System.Uri]"http://sharepointsite"; [Microsoft.SharePoint.SPOfficialFileHost] $ targetHost = New-Object "Microsoft.SharePoint.SPOfficialFileHost" $ action = [Microsoft.SharePoint.SPOfficialFileAction]::Move $ mode = [Microsoft.SharePoint.SPOfficialFileSubmissionMode]::None $ targetHost.Action = $ action $ targetHost.Explanation = "Move to Archive" $ targetHost.OfficialFileUrl = $ tgtUri $ targetHost.ShowOnSendToMenu = $ false $ targetDropSite = Get-SPSite "http://archivesite" $ targetDropWeb = Get-SPWeb "http://archivesite" $ DropLibUrl = "http://archivesite/DropOffLibrary/" $ listfiles = New-Object 'System.Collections.Generic.List[Microsoft.SharePoint.SPFile]' [Microsoft.SharePoint.OfficialFileResult] $ result = $ file.SendToOfficialFile($ file.Item.ContentType.Name, $ targetHost, $ null, $ mode, [ref] $ additionalInfo)