Delete a file and its history from TFS


What if you need to delete a file and all its history from tfs for some reason. Maybe someone checked in a password or api key?

tf destroy /startcleanup "$/" /collection:http://:8080/tfs/DefaultCollection

This also works for folders depending on how specific the filepath is. You can add /preview to see what files will be destroyed.

More Info at: https://docs.microsoft.com/en-us/azure/devops/repos/tfvc/destroy-command-team-foundation-version-control?view=vsts

notepad++ regex replace


Problem: I have a file with many variable length lines with a decimal number on the end (i.e. a transaction statement that was not formatted very well) and I needed to extract just the decimal value on the end.

Solution: I used the regular expression replace feature in Notepad++. The regular expression is some like "for each line match the decimal number at the end). The magic part is on the Replace with field I needed \1 to replace each line with just the matched section. I could probably have expanded on this to retain all the values and put tab separators in so it could copy and paste it into excel!


Import IIS logs into SQL Server table

There are lots of IIS log parsers out there, but I found a simple SQL script that will load them into your own SQL Server table for you to query how you like.

CREATE TABLE dbo.IISLOG (
 [DATE] [DATE] NULL,
 [TIME] [TIME] NULL,
 [s-ip] [VARCHAR] (48) NULL,
 [cs-method] [VARCHAR] (8) NULL,
 [cs-uri-stem] [VARCHAR] (255) NULL,
 [cs-uri-query] [VARCHAR] (2048) NULL,
 [s-port] [VARCHAR] (5) NULL,
 [s-username] [VARCHAR] (128) NULL,
 [c-ip] [VARCHAR] (48) NULL,
 [cs(User-Agent)] [VARCHAR] (1024) NULL,
 [cs(Referer)] [VARCHAR] (4096) NULL,
 [sc-STATUS] [BIGINT] NULL,
 [sc-substatus] [INT] NULL,
 [sc-win32-STATUS] [INT] NULL,
 [time-taken] [INT] NULL
)

BULK INSERT dbo.IISLOG
FROM 'c:\temp\u_ex171205.log'
WITH (
 FIRSTROW = 5,
 FIELDTERMINATOR = ' ',
 ROWTERMINATOR = '\n'
)


SELECT [cs-uri-stem], avg([time-taken])
FROM dbo.IISLOG
WHERE [cs-uri-stem] like '%.svc'
GROUP BY [cs-uri-stem]
ORDER BY avg([time-taken]) desc


This tip is based on this post, but contains fixed field lengths and bulk import statement.