Replace a string in a file with PowerShell

I have wanted to expand my PowerShell skills for some time, however I find it a steep learning curve. One thing I am learning is the result is worth it.

I recently needed to replace a string in a file. I searched a found the working parts I needed create this. I just wanted to post it here so I know where to come back and find it.

 

[CmdletBinding()]

param

(

    [Parameter(Mandatory=$True)]

    [string]$OldValue,

    [Parameter(Mandatory=$True)]

    [string]$NewValue,

    [Parameter(Mandatory=$True)]

    [string]$FilePath

)

(Get-Content $FilePath) |

Foreach-Object {$_ -replace "$OldValue","$NewValue"|

set-content $FilePath

 

A wonderful addition to this is you can even pop regular expressions into the $OldValue.

 

(Get-Content MySSAS.deploymenttargets) |

Foreach-Object {$_ -replace "<Server>(.*?)</Server>","<Server>__TargetDataBase__</Server>"}  |

set-content MySSAS.deploymenttargets

 

 

 

From Requirements to Deployment: The Modern SW Developer using TFS

On May 8th, the Scotia Bank Theatre, Richmond Street Toronto was the scene of another successful “ObjectSharp At the Movies” event. The event was recorded so you can watch again, share with colleagues or maybe you couldn’t make the presentation and just want to watch for the first time. Below is a quick synopsis of what I presented. Click here to enjoy the Video.

My goal for the morning was simple. As MC I needed to keep things moving, entertain the audience during lull's and show the 500+ registered attendees how great it will be when they upgrade and or start using TFS 2013 in under 30 minutes.

I Started things off with this slide showing Team explorer when TFS is your repository and when Git is your repository. Not much to say on the subject as Colin covered it in his presentation.

image

The new Build process in 2013 includes the ability to shell out to a batch file or powershell script from several steps including prebuild, postbuild, pretest and posttest. This is a great feature that I have been adding to build processes since 2010.

A lot of people didn’t like the fact that pending changes was incorporated into the Team Explorer. Several of the Team explore windows like pending changes and builds can be torn off the team explorer and float as their own windows.

My Work is not new to 2013 but worth mentioning. This window is a great view of all your Work In Progress, Suspended Work, Available Workitems and Code Reviews. Watch the video to see how you can easily switch context using Suspended work and change the query behind Available Workitems to show the work that is assigned to you.

Check out Code Lens inserted right in your code on classes and methods, showing you references to this code, changesets when this code was added and workitems associated to those change sets. This is a great connection from your code directly into TFS.

Release Management is the biggest and best new feature of TFS 2013. Watch and see how a code change can easily be deployed out to multiple environments all starting from your build.

Again click here to enjoy the Video.

MVP Consumer Camp (May 29th 2014)

clip_image002

Check out this great event that Microsoft is organizing at the Microsoft Store at Square One Shopping Centre in Mississauga – the first Canadian MVP Consumer Camp on Thursday, May 29th from 4pm to 9pm. some of my fellow MVPs will be there answering tech questions, showing off demos and the unique features of Microsoft devices. There will be prize draws, Q&A sessions, snacks and refreshments. 

MVPs are recognized exceptional, independent community leaders who share their passion, technical expertise, and real-world knowledge of Microsoft products with others. We speak at events, answer questions online, and have awesome technical blogs! 

For those of you who haven’t been to a Microsoft Store yet, they are amazing!  They have a huge selection of the latest products and gadgets with experts who can answer all of your questions.  If you can’t make the event, definitely try to drop in to a store to try the latest Xbox game, check out Windows 8.1 and its great touch features or to buy the latest and greatest Windows Phone.  The Nokia Lumia 1020 has an unbelievable camera by the way ;)

Do you have any questions about Surface, Windows, Office, Windows Phone or Xbox?  Do you want to learn about how to get the most out of your gadgets?  There will be an MVP there who can provide answers! Hope to see you there!

Register here!

Visual Studio Online Data Export

Now that TFS in the cloud or Visual Studio Online has gone to general availability. There are customers out there that might be rethinking the use of Visual Studio Online and would like to move to an on-premise solution.

If you are thinking that way, take advantage of this Data Export tool supplied by Microsoft while it lasts. The excerpt below is part of an article about the General Availability of VSO. There is a link to it from your VSO home page under news.

Data Export Window

Many of our users started out with VS Online before we’d painted much of a picture of what the future would look like. Some group of them may want to take this transition to GA as an opportunity to reconsider their ALM configuration and move to an on-premises TFS server. Starting today, we’re enabling a data export window for any customer that has been on the service and wants to “opt out”. For the next 6 weeks, you have the option to export your data from Visual Studio Online in a format that can be imported to Team Foundation Server 2013 Update 2. In order to get access to the export capability, contact customer support (vsoexportsupport@microsoft.com) and we’ll be sure to get it switched on right away and provide you instructions on what to do.

From what I have read on the ALM email thread. This is the best option, better than the TFS integration tools. It will get all your Data including work items and source control history, and is much higher fidelity than the migration toolkit.

It will only be around for 6 weeks so if you are planning this move get on it.

I am speaking at CTTDNUG this month

The April session of CTTDNUG will be yours truly doing – A Day in the Life of TFS 2013

Here is the announcement:

Join us on Wednesday April 16th for a session on TFS 2013 presented by Dave Lloyd, Microsoft ALM MVP!

Session Info

This will be a complete tour of what TFS 2013 can accomplish when used by a whole team (Dev’s, QA, BA, Product Owner). We will cover the product backlog and task boards, Teams, Storyboarding and Feedback requests. My Work and switching context, Git integration, Code Reviews. Creating Test plans and executing Test Cases, Exploratory Testing and Release Management. Throughout the presentation the floor will be open to any other aspects of TFS that you would like to talk about!

Speaker Bio

Dave Lloyd has 30 years’ experience in the IT industry designing and building software solutions for a large number of clients in varying industries. Dave is a seasoned project manager with a great deal of experience implementing process into development teams, from small and large ISV’s to in house development teams. Dave has also spent time during his career implementing test solutions for clients. Working with the most current automated test tools and implementing successful test environments. Dave brings to the table 25+ years of teaching experience. He has been awarded the ALM MVP designation for the past 4 years in a row

When?
Wednesday, April 16, 2014 from 6:30pm - 8:30pm
Pizza/pop will be served starting at 6pm

Where?
Country Hills Community Library, 1500 Block Line Road, Kitchener, ON

How to register?
Visit CTTDNUG’s site to view more details and to register for this event: http://www.cttdnug.org

Seats are limited so register early to reserve your spot!

At the Movies is Back

May 8th is the next At the Movies event from ObjectSharp. Click the poster below to register. You don’t want to miss this. 

clip_image001[6]

Toronto ALM User Group

I really need to stop ignoring my BLOG, I have lots of stuff to post, however I just keep forgetting to do it. Life gets so busy. Well it’s a new year and I am going to try and post something at least every two weeks. I want to say every week but I can’t see that happening. Smile

 

Since I run the Toronto ALM user group I should at least let people know what is coming up.

In January we had the last Canadian speaking appearance of Colin Bowern when he gave a great presentation sharing his thoughts on this topic: As with many things in software engineering there is rarely an answer that is always right, all the time – except locking your workstation when you walk away from your desk, no excuses there.  In the ALM space we have heavily integrated stacks like Microsoft TFS, Rational Team Concert, CollabNet TeamForge and Atlassian’s toolset, but we also have standalone tools that are focused on being the best at one thing alone. In this session we’ll walk through a particular stack of tools that can be used in .NET shops that have investments in other platforms such as PSAKE, TeamCity, xUnit, SpecFlow, Node and PowerShell. But bigger than this toolset we will compare and contrast the integrated and best-in-class approaches to make sure we understand the tool, the myth and the legends behind each. Bring your experiences and let’s have a rich discussion that will broaden our horizons on what is possible to help teams reduce friction and ship value faster.

Thanks again Colin your presentation was informative and very well received by the group.

In February we have Max Yermakhanov showing us the new Release Management Solution that comes in TFS 2013. This is Microsoft's newest acquisition from Canada’s own InCycle. Are you looking for a way to track your release process and start automating your deployments for repeatable success? Are you wanting to have automation that is the same across development, test, and even production environments? If so, come by and learn about release management tooling in TFS 2013.

Hope to see you at the meeting in February.

Teams in TFS

If you have not embraced Teams in TFS you should take a look at them. This is a wonderful feature that makes grooming backlogs by team so easy. 

Teams allow you to divide a TFS project up into products. From the TFS Control Panel in your web interface you can create a team:

image

I recommend you select Team Area. This will make the product backlog easier to use.

image

Once you have the Teams you want to assign Areas and Iterations to each team. This will give you different backlogs and sprints for each team. Select the new team in the control panel.

image

Create an Iteration for that team and set up the sprints/releases as children of the iteration you just created then assign them to the team by selecting them. Notice by the toolbar you must be in the control panel for this team.

image

Add Areas for the product under the teams area and select them for this team.

image

Now when you open the Web interface and select that team the backlog is filtered to only show work items for that team. It will only show this teams sprints and backlog items.

Change the view to the whole project and you will see everything for all teams again.

To switch between Teams the title bar of the TFS Web interface has a dropdown that shows the most frequently selected teams.

image

Select Browse all and you can switch to another teams view .

image

In my sample project I have many user stories, in various states.

image

image

 

 

 

 

 

When I switch to Fabrikam Fibers backlog. Everything is filtered for that team.

image

 

 

 

image

Visual Studio 2013 Canadian Launch

   

clip_image001

       
 

On December 4th, Microsoft Canada will be celebrating the launch of Visual Studio 2013 with an evening networking event for IT Development and Operations Leads. This is being held at E11even in downtown Toronto between 5 and 8pm.
Software change management is a costly and complex challenge that every customer faces. Over the last few years, our customers are increasingly sharing with us that this challenge has started to become a key blocker in their business.
With the launch of the Visual Studio 2013 wave of ALM tools, we are excited to share with you all that is new, including our Software Release Management solution. Instead of software releases being a problem to be dealt with, you’ll see real gains via consistent hand-offs and better integration between development and production. We are looking forward to hear from you and to learn more about your ALM stories.
Claude Remillard, co-founder of Montreal-based InCycle Software, will be leading this event. He’ll be talking about how a modern and automated release process can positively impact your organization, and how it can ensure a quality release process with reduced risk and quick roll back capabilities, all adding up to shorter release cycles – and fewer headaches for IT overall.
I look forward to you joining us for this evening – and please, to bring a colleague along – ideally someone who cares as much about the smooth release of software as you do!
Register now
5pm-8pm
E11even Restaurant
Private Dining Room
15 York St., Toronto, ON. M5J 0A3
If you prefer I not forward you these types of communications, just let me know. To learn how to manage your contact preferences for other parts of Microsoft, please read our Privacy Statement.

   
       

Sprint Reporting

I recently created a cool Sprint Report that is accurate to the hour. 

image

 

 

 

 

 

 

 

 

 

We have two scrum teams working simultaneously on separate sprint backlogs. Using the Teams feature in TFS 2012 we have created two Sprint teams and assigned each one their own iterations.

We also added a field to the User Story called Current Sprint, and changed the workflow so that when the User Story is set to Active the workflow automatically sets Current Sprint to yes. 

Then We wrote a query against the TFS Warehouse that grabs each teams backlog and sums the Story Points by State.

Another Query gets the current sprint based on the date for that team and calculates the number of days and the remaining days left in the sprint.

As you can see the result is a very nice concise report showing exactly where the team is to the nearest hour.

Also as you can see one team is mid sprint and the other is between sprints. The report reflects that also.