1

I have a powershell script that is copying files from a mapped drive into sharepoint and setting some meta data. All is working as expected with the exception of certain files lose most meta data when the file is checked in. The script works for the majority of the files which is the odd part.

This is a small portion of the script but I have narrowed it down to where I believe the problem is. Here I have several tests to see when the metadata is being lost... In tests 2b, 3a the title is still present. However after the checkin, test 3b returns no value in the title field.

Please keep in mind that this only happens on certain documents. Any suggestions appreciated. Also I am not getting any errors in these scenarios.

$spItem = $list.GetItemById($spItem.Id) 
$title_tmp = $spItem["Title"]
Write-Host "      Title Set Test 2b: $title_tmp" -ForegroundColor Yellow
WriteULS "UploadFinanceLibraryDocuments::Update SPItem End"

$fileCheckedOut = $spItem.File
Write-Host "Check out status: $($fileCheckedOut.CheckOutStatus)"
if($fileCheckedOut.CheckOutStatus -ne "None")
    {
        Write-Host "   Checking In $fileCheckedOut "-ForegroundColor Gray -NoNewline
        try{
            # Get Reference Again
            $spItem = $list.GetItemById($spItem.Id) 
            $title_tmp = $spItem["Title"]
            Write-Host "      Title Set Test 3a: $title_tmp" -ForegroundColor Yellow

            $fileCheckedOut.CheckIn("Checked in on Upload.")                    
            Write-Host " OK" -ForegroundColor Green         

            # Get Reference Again
            $spItem = $list.GetItemById($spItem.Id) 
            $title_tmp = $spItem["Title"]
            Write-Host "      Title Set Test 3b: $title_tmp" -ForegroundColor Yellow
            }
            Catch
            {...}
    }

Update

It appears as though this is related to .xlsx files....

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.