Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

PowerShell code not working import XML to SharePoint list

$
0
0
 

All hi, I don't understand why doesn't work? XML file from here - http://www.cbr.ru/scripts/XML_daily.asp?date_req=23/01/2015

if(!(Get-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction:SilentlyContinue))
{
Add-PSSnapin Microsoft.SharePoint.Powershell

#Set these two variables accordingly
$WebURL  = “http://sharepoint/Test”
$ListName = "Test"
$XMLFilePath = "C:\Test\XML\XML_daily_asp.xml"

#Get the Web
$web = Get-SPWeb $WebURL
#Get the List
$ProjectList = $web.Lists[$ListName]

#import xml file
$ProjectXmlFile = Get-Content $XMLFilePath

foreach ($XMLProject in $ProjectXmlFile)
 {
$NewProject = $ProjectList.Items.Add()
$NewProject["Title"] = $XMLProject.Value
$NewProject["NumCode"] = $XMLProject.NumCode
$NewProject["CharCode"] = $XMLProject.CharCode
$NewProject["Nominal"] = $XMLProject.Nominal
$NewProject["Name"] = $XMLProject.Name
$NewProject["Value"] = $XMLProject.Value
$NewProject.Update()
Write-Host "Has been Added to External Projects list!"
 }

Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>