magritton
8/5/2016 - 9:18 PM

This powershell exports a list out to a deliminated file. The second file import the data to another list.

This powershell exports a list out to a deliminated file. The second file import the data to another list.

    $webUrl = "https://xxxxx"
    $listName = "Deficiency Reports"
    # Open web and library
    $web = Get-SPWeb $webUrl
    $list = $web.Lists[$listName]
    $items = $list.items
    
    foreach ($item in $items)
    {
		$line = ""
		$i = 1
		try{
			write-host $item["ID"].ToString() -background yellow -foreground blue
			foreach($field in $item.Fields)
			{
				#$field.InternalName | out-file f:\temp\eRDR.txt -append
				if($i -lt 70 -and $item[$field.InternalName] -ne $null){
					$line +=$item[$field.InternalName].ToString() -replace "`r`n"," "
					$line += '~'
				}
				else{
					$line += '~'
				}
				$i++
			}
			$line | out-file f:\temp\eRDR.txt -append
		}
		catch{
			"Something strange occurred: $_" | out-file f:\temp\eRDRerror.txt -append
		}
    }