Hi,
I am trying to extract list data using C# code inside powershell. But when i tried doing so, i am facing errors below is the code
$Assem = (
“Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” ,
“Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
)
$Source=@"
namespace codeagainstLists
{
using Microsoft.SharePoint;
using System;
class Program
{
using (SPSite siteObj = new SPSite("
{
using(SPWeb webObj=siteObj.OpenWeb())
{
SPList listObj = webObj.Lists["EmployeeDetails"];
foreach(SPListItem itemObj in listObj.Items)
{
Console.WriteLine(itemObj.ID);
}
}
}
}
}
"@Add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp
@object=New-Object [codeagainstLists.Program]
Please correct the above code and help with the functionality of List Data.
Thanks and Regards,
Sivapratap
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Manpreet SinghRank #15 · 50.7K reputationPosted Jun 29, 2016, 1:09 PM EDT
Nanddeep NachanRank #38 · 35.2K reputationPosted Jul 8, 2016, 6:06 AM EDT