I am using powershell to read a csv file and then uploading the file to sharepoint. However, I would like to rename the file. how is it done? Is it done before I load the file from fileshare to document library. or during the add method. I am not sure. Please let me know.

$sourceFile = Get-ChildItem $i.FileLocation
$newFile = $docLibrary.RootFolder.Files.Add($destinationFolderPath,$sourceFile.OpenRead(), $true)

2 Answers 2


$theItem = $newFile.Item
$theItem["Name"] = $i.newfilename

where i is file stream and newfilename is the column name for new file name.

This works for me.


One other post here was answering something similar upload file to document library

Pay attention to the last part when name is changed.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.