PowerShell Script to Create a WorkItem

Here is the PoSh script I demonstrated at the Atlanta Code Camp for creating a workitem in Team Foundation Server.  It is quite possible that there is a better way to load private assemblies into a PoSh session, but this works.

I did not run the script in my presentation, but pasted sections into the shell, to demonstrate how PoSh allows you to create objects from .NET types and interact with them at the command prompt.

##############################################################################
##
## Create-Workitem.ps1
##
## This script is converted from the C# Work Item Edit sample in the Visual
## Studio 2005 SDK.  I have ignored error checking, so you must have a valid server,
## with at least one team project.
##
## The purpose of this script is to demonstrate how a developer can use the Windows 
## PowerShell to automate tasks using private .NET assemblies.
## 
## In order to run this or any other PowerShell script, you will need to configure
## your PoSh environment to run scripts.  Type Help Set-ExecutionPolicy at a PoSh
## prompt to learn more.
## 
##############################################################################

$key = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\VisualStudio\8.0

$dir = [string] (Get-ItemProperty $key.InstallDir)

$dir += "PrivateAssemblies\"

$lib = $dir + "Microsoft.TeamFoundation.WorkItemTracking.Client.dll"

[Reflection.Assembly]::LoadFrom($lib)

$lib = $dir + "Microsoft.TeamFoundation.Client.dll"

[Reflection.Assembly]::LoadFrom($lib)

"Please enter your Team Foundation Server Name:"
$server = [Console]::ReadLine()
$server = $server.Trim()

"Connecting to " + $server + "..."
$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($server)

$type = [Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore]

$store = [Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore] $tfs.GetService($type)

$workItem = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem($store.Projects[0].WorkItemTypes[0])

"Created a new work item of type " + $workItem.Type.Name

$workItem.Title = "Created by Windows PowerShell!"

$workItem.Save()

++Alan

Atlanta Code Camp Followup

I enjoyed presenting at the Atlanta Code Camp this weekend.  We had a speakers’ dinner the night before, and I got to meet most of the other presenters.  The room was long and narrow, though, so I did not meet a few people at the other end of the room.

In particular, I enjoyed discussing LINQ with Jim Wooley and Wally.  I got a good introduction to Visual Studio extensebility from Vinay Ahuja.  I had a fun exchange with Charlie Arehart and Geoff Hiten about the impedance mismatch that occurs between developers and DBAs on where to put data access logic.

My father traveled with me, which was fun.  This was my first Code Camp, and I was surprised by the amount of organization and coordination required to pull it off smoothly.  Brendon, Matt and Doug as well as the rest of the volunteers deserve lots of credit for putting this together for the community.

My session was in the first time slot of the day, and was well attended.  The audience seemed engaged in the material, and I enjoyed presenting.  I had to high-tail it back to Knoxville immediately following my session in order to attend my daughter’s ballet recital, so I didn’t get to see any of the other sessions.

There was some discussion of another Atlanta Code Camp in February.  If it happens, I would love to present again.  In addition to more Team System talks, I would like to do a developer focused presentation on Windows PowerShell.  Most of the current material is slanted toward administrators.

Finally, I owe a HUGE "thank you" to Noah Subrin for loaning me his laptop power cord.  I left mine sitting on the desk in Knoxville, where I tested everything before packing for Atlanta.  What a typical rookie mistake.  Thank’s Noah, you rock!

++Alan

Speed Up Your PowerShell

I’ve been having fun with the latest drop of PoSh.  I’ll be showing a demo of how to manage workitems on Team Foundation Server with a PoSh script at Saturday’s CodeCamp.

One annoyance with the current RC is that it is slow to start.  I saw a thread on the newsgroup about performance and found this nugget:

set-alias ngen C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ngen.exe
ls $pshome/*.dll |%{ngen install $_.fullname }

The ngen utility compiles .NET assemblies to native code.  Without this step, the PoSh process was performing a JIT compile on all the PoSh assemblies.  Apparently, this is supposed to happen at the end of installation, but doesn’t as a result of a bug.  For now, this makes my play… er, work with PoSh even more fun.

++Alan

Google Juice

I use a RSS aggregator to read the web.  This is a great way to organize and prioritize information.  Last week, however, I was surprised to see the following headline in my reader:

Alan Stevens from Knoxville

This was from a post on Wally McClure’s blog.  Wally and I are both speaking this weekend at the Atlanta Code Camp, and in October at DevLink.  I thought it was cool of Wally to publish this post, and link back to Cave Markings.  In fact, Wally is generally a cool guy, and you should check out his podcast if you haven’t already.

What is totally surprising to me, is that Wally’s post is the #4 result for Alan Stevens on Google this evening.  Furthermore, this humble blog is the #5 result!  Wow, thanks for the love, Wally.

++Alan

Behold the Fire Pit

Two Saturdays ago, I embarked on a project that I had been contemplating all winter.  I restored  the remains of a fire pit I built in 1994.  It had seen lots of neglect.  The brick lining had been removed, and it had eroded to a large bowl shape.

I improved on my initial design by making it deeper, and lining the bottom with brick, as well as the sides.  The top ring is composed bricks with one rounded edge, which looks quite nice.

Here’s a picture, but since a hole in the ground isn’t terribly interesting, I chose one with a pretty lady in it.  <G>

++Alan

I’m Speaking at DevLink 2006

devLink Technical Conference 2006This is going to be lots of fun. 

Already they have Eric Sink and Kevin McNeish on the schedule.  I’ll be busy trying to act cool.  You know, I hang out with these guys all the time.  They’re not my heroes or anything.  No really, I’m cool.

++Alan

Everybody Lost in the Cartoon War

Back in ’93 I was one of the Sunday school teachers in a class called “Church Across the Street.”  This was a terrific curriculum for Sixth Graders.  We would study a religion or denomination for a week or two, then we would attend a service.  It was extremely educational for the students and the teachers.  I began attending the Episcopal Church as a direct result of my involvement in this class.

When we studied Islam, we visited the local Mosque.  It was Awesome.  I didn’t like that the girls had to use a separate entrance, and cover their heads.  Females also prayed in a separate room.  Aside from the gender issues, my experience was totally positive.  The reverence for God was palpable.  Multiculturalism is not just a PC term in a US mosque.  There were men of every color worshiping fervently together.  I was floored by the experience. 

We had an adolescent boy show us the customs for ritual cleansing and explain their symbolic and practical purposes.  This young man had a very strong sense of identity and belonging.  His life had value and meaning.  I don’t have anything against Islam. 

What continues to irritate me is ignorance.  Fundamentalism of all kinds is ignorance.  There is no inerrant scripture. Even if there were, we each would have the choice if we wanted you use it to direct our choices.  I follow the premise of a Presbyterian minister that was quoted to me:  “I take the Bible seriously, not literally.”

Nobody wins when we give in to hate, fear and ignorance, and the result of the Mohammed cartoon brouhaha is that we collectively gave in.

You can find a good post-mortem here.

++Alan

Windows PowerShell

According to this, PowerShell nee MSH nee Monad is on the verge of release.

This is exciting news for me because I spent this week learning the tool. I have had requests to make bulk updates to work items in Team Foundation Server. I decided to investigate MSH as a platform for creating custom scripts to fulfill this request.

Now that it is on the verge of release, I won’t have to overcome resistance to deploying pre-release tools. Life is good.

++Alan

[UPDATE] Keith Hill suggests some new acronyms for the Windows PowerShell.  I vote for POSH.

Oh the posh posh traveling life, the traveling life for me…

Page 14 of 18« First...1213141516...Last »