0

We need to import the data from notepad file to sharepoint list/library using powershell script.

Actually we want to fetch data whatever present on notepad file need to come on Sharepoint list/library with columns. For example, in notepad files consist of data like, there were column name like name, address, phone number and pincode. Once we run script data need to come on SharePoint list/library with corresponding name, address, phone number and pincode details. We are using SP 2010.

Please provide if there is any script or workflow or ideas to achieve my request.

1 Answer 1

0

Below might get you started...

Suppose you have below CSV file where data is separated by comma for each columns.

Application Name,Application Vendor,Application Version,Install Count 
Microsoft Office Professional Plus 2013,Microsoft,15.0.4420.117,2 
Microsoft Silverlight,Microsoft,5.1.1411.0,2 
Microsoft Application Virtualization (App-V) Client Service Pack 1,Microsoft,5.0.114.0,2

Use below powershell script.

Setup the correct modules for SharePoint Manipulation

if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null ) 
{     
   Add-PsSnapin Microsoft.SharePoint.PowerShell 
} 
$host.Runspace.ThreadOptions = "ReuseThread"

Open SharePoint List

$SPServer="http://LAB-SPS1" 
$SPAppList="/Lists/Application List/" 
$spWeb = Get-SPWeb $SPServer 
$spData = $spWeb.GetList($SPAppList)

$InvFile="appinvent.csv" 

Get Data from Inventory CSV File

$FileExists = (Test-Path $InvFile -PathType Leaf) 
if ($FileExists) { 
   "Loading $InvFile for processing…" 
   $tblData = import-csv $InvFile 
} else { 
   "$InvFile not found – stopping import!" 
   exit 
}



   # Loop through Applications add each one to SharePoint 
"Uploading data to SharePoint…." 
foreach ($row in $tblData) { 
   "Adding entry for "+$row."Application Name".ToString() 
   $spItem = $spData.AddItem() 
   $spItem["Application Name"] = $row."Application Name".ToString() 
   $spItem["Application Vendor"] = $row."Application Vendor".ToString() 
   $spItem["Application Version"] = $row."Application Version".ToString() 
   $spItem["Install Count"] = $row."Install Count".ToString() 
   $spItem.Update() 
}

$spWeb.Dispose()

Thanks to Reference link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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