1

This is a cross-post from stackoverflow, upon the suggestion of a user there.

My organization is experimenting with new processes to coordinate developers as they integrate their code into our main branch. Right now it's just a basic task list in Sharepoint, but it seems to be doing the trick pretty well. However, there's a lot of tedious manual labor in the creation of those task tickets, and we're looking to improve this. To that end, I have two questions.

1) I've looked through the list of Powershell cmdlets for Sharepoint, but without being a Sharepoint wiz I don't see anything immediately obvious in terms of automated task creation. Can this be done, or are the cmdlets more for administrative (configuration) purposes rather than for usage?

2) Is this a horrible abuse of sharepoint? Ultimately we're just trying to create a centralized location for tasks to be registered with some basic information concerning task details, task owner, and completion status. If there's some obviously better way to do this I'm all ears since no matter what we do we're probably reinventing some wheel or another.

3 Answers 3

1

I'd say that one way you can definitely do this is by calling the Lists.asmx web service with your PowerShell script and adding items to the task list via that web service call. The nice thing about using the web service is that it doesn't require that you run the script directly on a SharePoint server in the farm, you just need to do it from a computer that can access the SharePoint site via a network connection and use credentials that have the right to add items to the list in the site. This blog post has a nice example of how this can be done, and while its written for SharePoint 2007 the same should pretty much hold true for 2010: https://blogs.msdn.com/b/powershell/archive/2010/06/24/using-new-webserviceproxy-to-get-modify-and-add-items-to-a-list-in-sharepoint-2007.aspx

If you'd rather, you can also write a PowerShell script that takes advantage of the SharePoint Object Model to insert items into the list, but that will require that the script be run from the SharePoint server itself. The SharePoint Object Model is made up of the .NET classes and libraries that SharePoint developers can use to create customizations and applications on top of SharePoint, and since PowerShell can access and use .NET objects in its scripts, you can incorporate the elements of the Object Model that create new list items to achieve what you want. This looks like a good example of how to do it via the Object Model, and I think the author has at least one other post on the subject you may want to check out: http://www.learningsharepoint.com/2010/08/19/adding-list-items-using-powershell-sharepoint-2010/

Do you need more info on how to do either of those with PowerShell? In general, the thing to remember is that just because there aren't cmdlets available out of the box with SharePoint that do what you want to do, there are still a lot of ways that you can use PowerShell to automate a lot of things within SharePoint.

1

1) Totally do-able from PowerShell.

2) No, IMO it's a good use of the task list. However some Devs might prefer using Tasks in TFS.

For the PowerShell, as pseudo script, you'll need to fix the correct field name and input data formats etc (use SharePoint Manager to find what the field names are)

#use the url of the site with your task list e.g http://mysite.net/siteB
$web = Get-SPWeb $WebUrl 
$list = $web.Lists[$TaskListTitle]

$task = $list.AddItem()
$item["Title"] = $Taskname
$item["StartDate"] = $startDate
$item["DueDate"] = $dueDate
$item["AssignedTo"] = $personToDoTask
$item.Update()

$web.Dispose()
0

There aren't any cmdlets for creating custom jobs, but the SharePoint API is still available so you could create an SPJobDefinition like you would in in C#. I haven't found anything for v4 with PowerShell but I would imagine the API hasn't changed.

I've never done this so I'm not 100% sure if it would work.

As for your second question, the solution you're looking for sounds something like something better suited for Team Foundation Server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.