I am using a PowerShell script to import list items from csv file to another SharePoint list
$SiteUrl = "http://mysite"
$ListName="Contacts"
$ImportFile ="c:\Scripts\EmpData.csv"
#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$Context.Credentials = $credentials
#Get the List
$List = $Context.web.Lists.GetByTitle($ListName)
#Get the Data from CSV and Add to SharePoint List
$data = Import-Csv $ImportFile
Foreach ($row in $data) {
#add item to List
$ListItemInfo = New-Object Microsoft.SharePoint.Client.ListItemCreationInformation
$Item = $List.AddItem($ListItemInfo)
$Item["FirstName"] = $row.FirstName
$Item["InfoDate"] = $row.InfoDate
$Item.Update()
$Context.ExecuteQuery()
}
For example, we assume the csv file contains a column called InfoDate with value 3/20/2018. After running the above script the InfoDate column in the destination list shows as 3/19/2018. I am not sure why this is happening and now to fix it.