Stock Illustration of a Busy White Person Holding And Talking On Three Corded Telephones What happened to the Rangers? PB030271Why the silence … my apologies, but due to personal circumstances I have been promoted to commander-in-chief at home for 3 weeks, which means I am performing both the mom and dad role at home, the Rangers role at work, attending a kernel debugging course and in between trying to balance all the worlds as time available is typically in the negative. I am not sure whether it is more complex to manage a Rangers project or my sons soccer, swimming, school and extra-curriculum activities … when the dust settles in just under two weeks, I may take some time out and make a decision :) Then again we do not have much dust, because the past 2 weeks have been solid rain, strong winds and chilly temperatures in Vancouver … no, neither swimming (which is mainly in-doors in this country), nor soccer (which is outdoors and the soccer season is winter, not summer as in South-Africa) are cancelled.

Lovely picture of an early fairly clear-sky morning…

The Rangers have been hard at work, getting the completed solutions to ship on Codeplex … we have shipped one and have five in the queue … starting new projects, and continuing work on other currently active projects. One of the imminent ones is the virtualisation initiative, which includes a set of pre-installation and post-installation PowerShell scripts, automating the configuration, optimisation and cleanup of our images generated by the Rangers VM factory.

While the main ship is in awaiting the champagne bottle to strike and notify “shipment”, we have a smaller ship that is piggy-backing on the main initiative and creating automation scripts for the hands-on-lab (HOL) environments each Rangers project must deliver as part of its deliverables. I thought that instead of continued silence I could share one of the scripts that Robert and I have created and have been troubleshooting for a while.

In essence this script creates a set of HOL users and adds them to the relevant Team Foundation Server groups.

   1: # Copyright © Microsoft Corporation.  All Rights Reserved.
   2: # This code released under the terms of the 
   3: # Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
   4: #
   5: #<#  
   6: #.SYNOPSIS  
   7: #   This script configures the enviroment for the hands on labs scenarios.
   8: #    It is only intended to be run after the TFS enviroment is fully configured.
   9: #
  10: #.DESCRIPTION  
  11: #    This script performs the following steps:
  12: #     1) Creates the sample users
  13: #     2) Adds the sample users to the correct TFS groups
  14: #
  15: #.NOTES  
  16: #    File Name  : 3-hol.ps1  
  17: #    Author     : VSTS Rangers 
  18: #    Requires   : PowerShell V1
  19: #
  20: #.LINK  
  21: #   This script posted to:  
  22: #        http://???.codeplex.com 
  23: #    License:
  24: #        http://opensource.org/licenses/ms-pl.html
  25: #
  26: #.EXAMPLE  
  27: # .\3-hol.ps1
  28: #> 
  29:  
  30: #Simply writes a blank to the screen
  31: function blankLine
  32: {
  33:     Write-Host -Object:""
  34: }
  35:  
  36: #Get the machine hostname
  37: $hostname = hostname
  38:  
  39: $projectName = ""
  40:  
  41:  
  42: function introduction
  43: {
  44:     blankLine
  45:     blankLine
  46:     Write-Host -ForegroundColor Yellow -Object "Welcome to the TFS 2010 Virtual Machine Configuration Script - Hands On Labs Setup"
  47:     "
  48:  
  49: Copyright © Microsoft Corporation.  All Rights Reserved.
  50: This code released under the terms of the 
  51: Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
  52:  
  53: "
  54:     Write-Host -ForegroundColor Red -Object "Note: Please make sure you have checked the README.TXT file for information about pre-requisites and known issues prior to running this script."    
  55: "
  56:  
  57: This script is intended to configure the TFS virtual machine. 
  58:  
  59: WARNING: THIS IS NOT INTENDED FOR PRODUCTION USE!
  60:  
  61: This script will
  62: - Create sample TFS user accounts
  63: - Assign TFS users to TFS groups
  64:  
  65: If you wish to abort press Ctrl+C now, else 
  66:     
  67: Press any key to begin..."
  68:   $inputKey = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp")      
  69: }
  70:  
  71: function createUser([string]$accountName, [string]$password, [string]$name) 
  72: {  
  73:     $computer = [adsi] "WinNT://$hostname"  
  74:     $user = $computer.Create("User", $accountName)      
  75:     $user.SetPassword($password)
  76:     $user.SetInfo()         
  77:     $user.FullName = $name
  78:     $user.put("UserFlags",65536 -bor 64)
  79:     $user.SetInfo()         
  80: }
  81:  
  82: function createSampleAccounts
  83: {
  84:     createUser "michaf" "P@ssw0rd" "Michael Affronti (PM)"
  85:     createUser "aprist" "P@ssw0rd" "April Stewart (Dev Lead)"
  86:     createUser "dorikr" "P@ssw0rd" "Doris Krieger (Dev)"
  87:     createUser "abuobe" "P@ssw0rd" "Abu Obeida Bakhach (Dev)"
  88:     createUser "chriko" "P@ssw0rd" "Christine Koch (Tester)"
  89:     createUser "chriba" "P@ssw0rd" "Chris Barry (Business Stakeholder)"
  90:     createUser "robiwo" "P@ssw0rd" "Robin Wood (End User)"
  91: }
  92: function addToTFS([string]$accountName, [string]$groupname, [string]$targetProjectName = "") 
  93: {  
  94:     $target = ""
  95:     if ($targetProjectName -ne "")
  96:     {
  97:         $target = "[" +$targetProjectName + "]\" +$groupname
  98:     }
  99:     else
 100:     {
 101:         $target = $groupname
 102:     }
 103:     
 104:     if (!$accountName.Contains("\"))
 105:     {
 106:         $accountName = $hostname + "\" + $accountName
 107:     }
 108:     
 109:     $currentLocation = Get-Location
 110:     Set-Location "c:\Program Files\Microsoft Team Foundation Server 2010\Tools"
 111:     $argument = $hostname + "/defaultcollection"
 112:     .\tfssecurity /g+ $target n:$accountName /collection:$argument
 113:     Set-Location $currentLocation
 114: }
 115:  
 116:  
 117: function addSampleAccountsToGroups
 118: {    
 119:     addToTFS "michaf" "Team Foundation Administrators"
 120:     addToTFS "aprist" "Team Foundation Administrators"
 121:     addToTFS "dorikr" "Contributors" $projectName
 122:     addToTFS "abuobe" "Contributors" $projectName
 123:     addToTFS "chriko" "Contributors" $projectName
 124:     addToTFS "chriba" "Contributors" $projectName
 125:     addToTFS "robiwo" "Readers" $projectName
 126: }
 127: Clear-Host
 128: introduction
 129: $projectName = Read-Host -Prompt "Project name to add contributors and readers to"
 130: createSampleAccounts
 131: addSampleAccountsToGroups

What’s next? When the Microsoft PowerTools for Visual Studio 2010 ship for 2010 BETA-2, in particular the FTPT program, we will be adding the automatic creation of Team Projects and the automated setup of branches, workspaces, etc.

Here is a snippet of such a script under construction:

   1: function CreateHOLSpaceForTP_B
   2: {
   3:  #Create team project with tfpt (TFPT createteamproject TP-B.xml)
   4:  #... waiting for working 2010 BETA-2 edition
   5:  
   6:  #Create Workspace
   7:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' workspace /new TP-B /noprompt
   8:  
   9:  #Do the mapping
  10:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' workfold  /unmap $/
  11:  
  12:  #Create the VC space as per HOL
  13:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' workfold  /map $/TP-B 'C:\HOL\Source Code\Demo\Sandbox-B' /workspace:TP-B
  14:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' add       'C:\HOL\Source Code\Demo\Sandbox-B\Main' /recursive
  15:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' checkin   'C:\HOL\Source Code\Demo\Sandbox-B\Main' /recursive /noprompt
  16:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' branch    'C:\HOL\Source Code\Demo\Sandbox-B\Main’  ‘$/TP-B/Dev’
  17:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' checkin   'C:\HOL\Source Code\Demo\Sandbox-B\Dev' /noprompt
  18:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' add       'C:\HOL\Source Code\Demo\Sandbox-B\Dev\HelloWorldDemo' /recursive
  19:  &'\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe' checkin   'C:\HOL\Source Code\Demo\Sandbox-B\Dev' /recursive /noprompt
  20: }
  21:  
  22: CreateHOLSpaceForTP_B

The above scripts are both under construction, not supported and shared only to show you what we are busy with and what is possible.

For today and the next two days I will be exploring kernel debugging and therefore will be focusing my blogs on the exciting world of debugging again.