First off is the Quote of the Month for September.  My brother-in-law texted me this great quote in reference to the Detroit Lions beating the Washington Redskins over the weekend.  Best headline I’ve heard so far: “Washington bails out Detroit once again” … God my Skins Suck. Great headline.

 

Now on to the more serious matters for this post.  You’ll need Powershell 1.0 for this and it will help to have PowerGUI.  The script is not meant to be a black box.  Edit it to suit your needs and enjoy.  Hope you find this useful.  Replace <MyUsername> with your domain or workstation username or remove the Out-File from the end of the script.  Replace <Directory under Source Safe> with the root path of the source safe files you want to retrieve.

		 1: [string]$filepath = "c:Documents and Settings<MyUsername>DesktopOutput.txt"
		 2: [string]$projectroot = "<Directory under Source Safe>"
		 3: $filelist = &"c:Program FilesMicrosoft Visual SourceSafess.exe" DIR "<Directory under Source Safe>" -R
		 4:  
		 5: Write-Output $projectroot
		 6:  
		 7: [string]$proj = ""
		 8: [string]$project = ""
		 9: [string]$subfolder = ""
		 10:  
		 11: $allfiles = @()
		 12:  
		 13: foreach ($f in $filelist)
		 14: {
		 15: if ($f.StartsWith("$") -eq $true -and $f.EndsWith(":") -eq $True)
		 16: {
		 17: $proj = $f.Substring(0, $f.Length - 1)
		 18: if ($projectroot.Length -lt $proj.Length)
		 19: {
		 20: $endofprojectmarker = $proj.SubString($projectroot.Length + 1).IndexOf("/")
		 21: if ($endofprojectmarker -lt 0)
		 22: {
		 23: $project = $proj.SubString($projectroot.Length + 1)
		 24: $subfolder = "/"
		 25: }
		 26: else
		 27: {
		 28: $project = $proj.SubString($projectroot.Length + 1).Substring(0, $endofprojectmarker)
		 29: $subfolder = $proj.SubString($projectroot.Length + 1).Substring($endofprojectmarker + 1)
		 30: }
		 31: }
		 32: }
		 33: else
		 34: {
		 35: # Remove all project files.
		 36: # Remove all sub project files because recursive takes care of
		 37: # enumerating the sub files.
		 38: # Remove all number of items files.
		 39: # Remove all blank lines.
		 40: if ($f.Contains(".csproj") -eq $false -and
		 41: $f.StartsWith("$") -eq $False -and 
		 42: $f.EndsWith("item(s)") -eq $False -and
		 43: $f.Length -gt 0 -and
		 44: $f.Contains("No items found") -eq $False -and
		 45: $f.Contains(".sln") -eq $False -and
		 46: $f.Contains(".vsmdi") -eq $False -and
		 47: $f.Contains(".vssscc") -eq $False -and
		 48: $f.Contains("No items") -eq $False -and
		 49: $f.Contains("/" + $project) -eq $False)
		 50: {
		 51: $obj = New-Object PSObject
		 52: $obj | Add-Member NoteProperty -Name "Project" -Value $project
		 53: $obj | Add-Member NoteProperty -Name "File" -Value $f
		 54: $obj | Add-Member NoteProperty -Name "SubFolder" -Value $subfolder
		 55: $allfiles += $obj
		 56: }
		 57: }
		 58: }
		 59:  
		 60: $allfiles | Format-Table | Out-File -FilePath $filepath

The output from this is contained in a file on your desktop and is as follows:

		 1: ChartModule ChartControlModule.cs / 
		 2: ChartModule qtowmxfc.tmp_proj / 
		 3: ChartModule AssemblyInfo.cs Properties 
		 4: ChartModule ITimeSeriesService.cs Services 
		 5: ChartModule IValueSeriesService.cs Services 
		 6: ChartModule RandomMonthSeriesService.cs Services 

If you looked into VSS, you would find these files under the <Directory under Source Safe>/ChartModule project.  AssemblyInfo.cs would be found in the sub project of ChartModule called Properties.