I am trying to upload a file from a local drive to a sharepoint doc lib, this much I have been able to find, however, I also want to update a column relative to the file, foe example, I have a company column that I want to populate along with the upload, how would I modify this powershell script to do so? Any help would be awesome!
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
function UploadFile($Web, $DocLibName, $FilePath)
{
$List = $Web.GetFolder($DocLibName)
$Files = $List.Files
$FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1)
$File= Get-ChildItem $FilePath
$Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false)
}
$SiteUrl = "https://foo.foo.com"
$Web = Get-SPWeb $SiteUrl
UploadFile $Web "DocLib" "C:\x.pdf"
Write-Host "Documents Uploaded to $SiteUrl"
$web.Dispose()