TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sivapratap Kurapati
NA
95
39.1k
Embed C# code inside Powershell to extract List Data
Apr 19 2016 9:45 AM
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("<servername"))
{
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
Reply
Answers (
2
)
How to login the share point at programmatically using c#
Enable Folder Creation using JSOM