Sunday, March 1, 2015

TFS UNDO others checkout - recursively for all users

As a TFS admin, time and again I have to archive/move the branches to other folders to make sure that our TFS folders are not cluttered with old un-used branches. But when I try to MOVE the branches, if any of the developers have checked-out a file from that branch in their workspace then TFS doesn't allow me complete the operation. I have to undo all those checkouts (by all the users) before I can MOVE the branch.

The TFS Power tools provides some relief here. It helps you to undo others checkout from within Visual studio (or command line). Right click the branch -> Find -> Find by Wildcard. You can see the screenshots below:




But the catch is that it can only perform the UNDO operation for one user at a time. So in a large organization if you have 100-200 developers working in a branch, that means if 100 developers have each checked out 1 file each from the branch, then I will have to press UNDO button 100 times to make the branch checkout free.

I searched extensively and couldnt find any out of the box solution. Finally the solution that I came up for this it to create a powershell script which queries the TFS (for a specific branch) to find the list of files checked out to users, then it loops through the user list and UNDO all the files checked-out to that user under the branch.

Link Github repo


$tfLocation = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" 
$tfsBranchName = “{enter your TFS branch/folder/file location}“ 
$tfsCollectionName = "http://tfsserver:8080/tfscollection” 
$logFile = “{log file location}“ 


Function GetUserFileList($tfsBranchName) 
try{
        # Array to hold the object (user/file/workspace) objects 
        $arrayFileUserMapping = @(); 
        
        If (Test-Path $logFile) 
        { 
                Remove-Item $logFile; 
        } 
        
        Set-Location $tfLocation; 
        
        .\tf.exe status $tfsBranchName /collection:$tfsCollectionName /user:* /format:detailed /recursive >> $logFile; 
        
        Set-Location $PSScriptRoot; 
        
        foreach ($line in Get-Content $logFile) 
        {         
                If($line.StartsWith("$")) 
                { 
                        $objCurrFile = New-Object System.Object; 
                        $splitStringFile = $line -Split ";"; 
                        $objCurrFile | Add-Member -type NoteProperty -name FileName -value $splitStringFile[0];                         
                } 
                Else 
                { 
                        foreach ($singleLine in $line){ 
                                If($singleLine.StartsWith("  User")) 
                                { 
                                        $splitStringUser = $singleLine -Split ":"; 
                                        $objCurrFile | Add-Member -type NoteProperty -name User -value $splitStringUser[1];                                                                                 
                                } 
                                ElseIf($singleLine.StartsWith("  Workspace")) 
                                { 
                                        $splitStringWS = $singleLine -Split ":"; 
                                        $objCurrFile | Add-Member -type NoteProperty -name Workspace -value $splitStringWS[1];                                 
                                } 
                        } 
                } 
                
                $arrayFileUserMapping += $objCurrFile; 
        }         
                
        $uniqueWorkspaceArray = $arrayFileUserMapping | Group Workspace 
        $uniqueUserArray = $arrayFileUserMapping | Group User 
        
        for($i=0;$i -lt $uniqueUserArray.count; $i++) 
        { 
                $workspaceWOSpace = $uniqueWorkspaceArray[$i].Name.Trim() 
                $userWOSpace = $uniqueUserArray[$i].Name.Trim() 
                $workspace = $workspaceWOSpace + ";" + $userWOSpace; 
                
                Set-Location $tfLocation; 
                .\tf.exe undo $tfsBranchName /collection:$tfsCollectionName /workspace:""$workspace"" /recursive /noprompt;                 
                Set-Location $PSScriptRoot; 
        } 
}
Catch [system.exception]
  {
  "Oops, something's wrong!!!"
  }

GetUserFileList($tfsBranchName);$tfLocation = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" 
$tfsBranchName = “{enter your TFS branch/folder/file location}“ 
$tfsCollectionName = "http://tfsserver:8080/tfscollection” 
$logFile = “{log file location}“ 
Function GetUserFileList($tfsBranchName) 
try{
        # Array to hold the object (user/file/workspace) objects 
        $arrayFileUserMapping = @(); 
        
        If (Test-Path $logFile) 
        { 
                Remove-Item $logFile; 
        } 
        
        Set-Location $tfLocation; 
        
        .\tf.exe status $tfsBranchName /collection:$tfsCollectionName /user:* /format:detailed /recursive >> $logFile; 
        
        Set-Location $PSScriptRoot; 
        
        foreach ($line in Get-Content $logFile) 
        {         
                If($line.StartsWith("$")) 
                { 
                        $objCurrFile = New-Object System.Object; 
                        $splitStringFile = $line -Split ";"; 
                        $objCurrFile | Add-Member -type NoteProperty -name FileName -value $splitStringFile[0];                         
                } 
                Else 
                { 
                        foreach ($singleLine in $line){ 
                                If($singleLine.StartsWith("  User")) 
                                { 
                                        $splitStringUser = $singleLine -Split ":"; 
                                        $objCurrFile | Add-Member -type NoteProperty -name User -value $splitStringUser[1];                                                                                 
                                } 
                                ElseIf($singleLine.StartsWith("  Workspace")) 
                                { 
                                        $splitStringWS = $singleLine -Split ":"; 
                                        $objCurrFile | Add-Member -type NoteProperty -name Workspace -value $splitStringWS[1];                                 
                                } 
                        } 
                } 
                
                $arrayFileUserMapping += $objCurrFile; 
        }         
                
        $uniqueWorkspaceArray = $arrayFileUserMapping | Group Workspace 
        $uniqueUserArray = $arrayFileUserMapping | Group User 
        
        for($i=0;$i -lt $uniqueUserArray.count; $i++) 
        { 
                $workspaceWOSpace = $uniqueWorkspaceArray[$i].Name.Trim() 
                $userWOSpace = $uniqueUserArray[$i].Name.Trim() 
                $workspace = $workspaceWOSpace + ";" + $userWOSpace; 
                
                Set-Location $tfLocation; 
                .\tf.exe undo $tfsBranchName /collection:$tfsCollectionName /workspace:""$workspace"" /recursive /noprompt;                 
                Set-Location $PSScriptRoot; 
        } 
}
Catch [system.exception]
  {
  "Oops, something's wrong!!!"
  }
GetUserFileList($tfsBranchName);

Saturday, September 13, 2014

MV Pages


MV (Memory Verse) Pages

1. Helps you learn important bible verses.
2. Includes all the bibles verses which defines the Christian faith
3. All the verses are available in 7 different bible versions for your convenience.

References - 2:7 Series verses by the Navigators (Navpress).











Tuesday, February 12, 2013

SiteMinder R12 CR11 Release with IIS7.0 Errors!!!


Quick note to all the people out there who might run into this issue.

I had developed a web application for a group in our company around 2 years back, it runs on the 3.5 ASP.Net framework and is hosted on a Windows 2008 R2 server IIS 7.0 and the application is protected with SiteMinder. Application used the DEVEXPRESS third party tool within. Last Monday I got a call from the team that the application is down and I need to look at it as the support team was not able to figure out anything.

The only change that had happened to that server was a SiteMinder upgrade from R12 CR07 to R12 CR11.

The first issue I found on the server was that the access rights for the "Network Service" user was all messed up. It didn't have access to the ASP.NET temp folders which caused the application to error out. Gave access to that particular temp folder and the application started coming up.

Now to the interesting part, since the application was protected using SiteMinder we authorize users by looking at the HTTP server variables passed on by SiteMinder. We provide the functionality based on the AD group membership. Everything was fine when the user logged into the first page, when they navigate to a page within the website, all the authorization goes off and the application considers the users as if they have only view rights. Basically the HTTP server variables did not persist across the pages.

Once the SiteMinder R12 CR07 version was installed back, everything started working as expected. We have raised a query with the MS guys about this, will let you know what happens.

It took as for a while to figure this out especially with an application which doesnt log or do error handling :) Dont blame me, they had only one month to get that application out and I had lot of other things to worry about then than logging!

Saturday, March 17, 2012

Love at its best!




"As we grow older together, As we continue to change with age, There is one thing that will never change. . . I will always keep falling in love with you..."

Norcross, Georgia

Sunday, December 25, 2011

40000 LED light Tree in Minnesota!




This tree is at Cedar Ave & Old Shakopee Rd. An eternal bliss!!! There are 40000 led lights on that tree. The family puts it up every year, just for the joy of Christmas! :)

Sunday, August 14, 2011

July 4th 2011 - Fireworks!





‎"All architecture is great architecture after sunset" :)

Monday, August 8, 2011

Newseum - Pulitzer Photo Gallery


If it makes you laugh,
if it makes you cry,
if it rips out your heart,
that's a good picture......

Wednesday, July 20, 2011

Its amazing how people can change in just a couple of months...

Its amazing how people can change in just a couple of months...

Un-freaking-believable. Period.

Friday, July 1, 2011

Sunrise - June 29th 2011 - Minneapolis, MN










I had been working overnight for the past 2 weeks, there was a release that I had to take care off! The only good thing that came out of the 2 weeks of slogging was the daily sunrise that I was able to see which otherwise I would never have seen (waking up at 530am noways). Believe me its a bliss, and unless you see it you will never appreciate it! How wonderful is God and his creations! :)