I needed a way to set up developer machines quick for access to a new Team Foundation Server rollout awhile back. Normally to set up a workspace on each dev’s machine I’d have to do the following:
A. Teach everyone how to set up workspaces
B. Show them how to get latest
C. Hope they don’t accidentally (or purposely) mess it up.
“C” is my main problem. 80% of users mess it up the first time. I cant blame them, TFS is a paradigm shift and it takes some getting used to. Just like going from VSS to SVN, it takes some getting used to.
To mitigate the risk of going well over my estimated time for installation of the system across the teams I decided to write a PowerShell script to do it for me. However, it is, well clunky. I’ve since improved it to the version below … however, it still has is "clunkiness" to it. But the best part about it is… IT WORKS. So fee free to use it to set up your TFS environments.
Prereq’s to get the script to run
- Users must have .NET 3.5 installed.
- Users must have Visual Studio 2008 installed
- Users must have the Team Foundation Client Installed
- Users must have been added to the proper security groups in TFS (if you’ve set up TFS already this should be easily accomplished through AD and groups).
- Users must have PowerShell (sometimes this is a sticking point with clients, but IMHO I truly believe EVERY developer should have PowerShell – more on this later)
- PowerShell must have the execution policy set to RemoteSigned/AllSigned (if you plan to sign this script, which I have not) or you can set it to Unrestricted (which is what I prefer, just be safe in what you run – read the script before you run it). More on execution policies here.
After that is taken care of, have the user can download this script, run it, and their workspace will be mapped and files will be downloaded. Note, this script may take awhile to run because it downloads all workspace files to your machine.
# Script that will: # 1. Create a workspace. Workspacce Name: <ComputerName>_Root # 2. Get the latest code from repository $tfsServer = "TFSRTM08" $userName = [system.environment]::UserName; $computerName = [system.environment]::machinename $workspaceName = $computerName + "_" + $userName +"_WS" #Use 'WS' as an acronym for "WorkSpace" $folderName = "C:\TFS"; # Set up the TF Alias</pre> # Find where VS is installed. $key = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0 $dir = [string] (Get-ItemProperty $key.InstallDir) Set-Alias tf "$dir\tf.exe" Write-Progress -Activity "Initializing Tree" -Status "Percentage Complete" -PercentComplete(10) # Create the folder echo "Creating folder: $folderName" new-item -itemtype directory -path $folderName -force echo "Completed Creating folder: $folderName" [system.environment]::newline Write-Progress -Activity "Initializing Tree" -Status "Percentage Complete" -PercentComplete(20) # Move to folder echo "Navigating to $folderName..." cd $folderName echo "Arrived at $folderName" [system.environment]::newline Write-Progress -Activity "Initializing Tree" -Status "Percentage Complete" -PercentComplete(30) # Delete the workspace if it exists. echo "Deleting workspace (if exists): $workspaceName" $expr = "tf workspace /delete " + $workspaceName + " /noprompt" $output = invoke-expression $expr echo "Done deleting workspace." [system.environment]::newline Write-Progress -Activity "Initializing Tree" -Status "Percentage Complete" -PercentComplete(40) # Create the workspace echo "Creating workspace: $workspaceName" $expr = [system.string]::Format("tf workspace /new /computer:{0} /server:{1} /noprompt {2}", $computerName, $tfsServer, $workspaceName) $output = invoke-expression $expr echo "Done Creating workspace: $workspaceName" [system.environment]::newline Write-Progress -Activity "Downloading Entire Source Tree" -Status "% Complete - this bar will not move for awhile. This process takes awhile." -PercentComplete(50) # Get the latest echo "Getting the latest code from: $tfsServer. This could take awhile..." $expr = "tf get"; $output = invoke-expression $expr echo "Done getting latest." Write-Progress -Activity "Initializing Tree" -Status "Percentage Complete" -PercentComplete(100) echo "Tree initialization is complete."
You can copy the above into a InitializeScript.ps1 file and then run it from any machine that has the pre-req’s installed. Enjoy.
Decorating Small Space says
decorating
, what makes some men swoon (a beat-up leather recliner,
…
Whatever it is, the more you can make it embody the
space
,
…
1603602377 says
http://www.louisvuittonpurses-bags.net Louis Vuitton Purses
http://www.louisvuittonhandbags-lv.com LV Bags
http://www.cheaplouisvuitton-bags.net Cheap Louis Vuitton
http://www.louisvuitton0.com Louis Vuitton
http://www.louisvuittonoutletsun.net Louis Vuitton Sunglasses
http://www.louisvuittonhandbags-lv.com Louis Vuitton Handbags
http://www.coachsoutletonline.org Coach Online Outlet
http://www.coachfactorysoutletonline.org Coach Factory Online
http://www.coachsfactoryoutlet.net Coach Factory
http://www.coachsoutletstoreonline.com Coach Outlet
http://www.alouisvuittonhandbags.com Authentic Louis Vuitton
http://www.burberryscarfoutlete.net Burberry Outlet
http://www.coachsoutletonline.org Coach Factory Outlet Online
http://www.e-louisvuittonoutlet.net Louis Vuitton Outlet
http://www.burberryscarf-outlet.com Burberry Outlet
http://www.coachfactoryoutletonlinstores.net Coach Factory Outlet Online
http://www.cheapcoachsbags.net Coach Bags
http://www.louisvuittonpurses-bags.net Louis Vuitton Bags
http://www.chanelbags-max.com Chanel Bags
http://www.louisvuittonbagsonline.net Louis Vuitton Bags
http://www.louisvuittonoutletsz.com Louis Vuitton Outlet
http://www.burberrybags-sale.net Burberry Bags
http://www.coachfactorysoutletonline.org Coach Factory Outlet Online
http://www.chanelhandbags-bags.net Chanel Bags
Coach Outlet Online says
http://www.mycoachoutletstoreonline.com
Coach Outlet Online says
http://www.mycoachoutletstoreonline.com
oakleys says
YT4M327CJS02QNU
Welcome to Oakley Sunglasses Hut to buy cool and cheap oakleys sunglasses.
Oakleys says
WTTAQADLGKLGWRR like it very much!
Coach Factory Outlet says
http://buycoachfactoryoutletsz.com