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 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Nanddeep NachanPosted Jul 8, 2016, 10:06 AM
Manpreet SinghPosted Jun 29, 2016, 5:09 PM