You are currently browsing the archives for the Utilities category.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Aug | ||||||
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | ||
- IIS (1)
- Open Source (1)
- Performance (3)
- Personal (2)
- Powershell (1)
- SQL (1)
- SQL Server (20)
- T-SQL (14)
- Uncategorized (6)
- Utilities (4)
- Windows OS (13)
- 23. August 2010: Alert for long-running SQL datbase backups
- 7. April 2010: Learning SMO & Powershell
- 25. February 2010: SQL Generators for moving database files
- 28. January 2010: Index to Filegroup mapping
- 20. January 2010: PowerShell Script to Clean Up Old Files Based on Age
- 7. January 2010: Quick & Dirty way to identify orphan files
- 29. July 2009: Trigger Mass Enable / Disable
- 29. June 2009: Moving Master and Resource databases
- 11. June 2009: Quick and Dirty CSV import to SQL Server
- 2. February 2009: Getting data file space usage
Archive for the Utilities Category
PowerShell Script to Clean Up Old Files Based on Age
20. January 2010 by admin.
Here’s an extremely concise PowerShell script to remove old files. You could use it to enforce a policy that keeps 90 days of ETL input files on a server. Files older than that would purged with this script. The script would be invoked by a SQLAgent CMDExec task or a Windows Task Scheduler job.
#Powershell Script to delete files older than a certain age
$intFileAge = 90 #age of files in days
$strFilePath = “c:\archive” #path to clean up
#create filter to exclude folders and files newer than specified age
Filter Select-FileAge
{
param($days)
If ($_.PSisContainer) {}
# Exclude folders from result set
ElseIf ($_.LastWriteTime -lt (Get-Date).AddDays($days * -1))
{$_}
}
get-Childitem -recurse $strFilePath | Select-FileAge $intFileAge ‘CreationTime’ | remove-item
Posted in Utilities, Windows OS | Print | 3 Comments »
Converting an existing Perfmon .BLG file to CSV
17. December 2008 by Bennett.
You may run across the situation where you need to import an existing Perfmon (or System Monitor) binary log file into and Excel spreadsheet or SQL database. The obvious first step is to convert it to CSV format. It took googling numerous forums to figure out how to do this, so I thought that I’d document it here for future reference.
The relog.exe utility, which ships with the OS, has the ability to convert between Perfom log file formats and merge several log files into one file. It has some nice filtering capabilities including filtering by time, counters, and nth record. Example syntax for simply converting between file formats:
relog -f csv inputfile.blg -o outputFile.csv
You can display all the options by simply typing relog -? at the command prompt.
Posted in Utilities, Windows OS, Uncategorized | Print | No Comments »
MD5 Hash Utilities
30. March 2008 by Bennett.
FCIV.EXE is a handy little utility to snap a MD5 hash of a single file or multiple files. Optionally it can recurse directories and produce XML output. http://support.microsoft.com/kb/841290
MD5SUM.EXE is a more commonly used utility that runs on a number of different platforms. A good Wikipedia article with links can be found here and a Win32 binary can be found here.
Posted in Utilities | Print | No Comments »
Open Source Diff Tool
3. September 2007 by Bennett.
Interesting tool: http://winmerge.org/
To quote the authors: WinMerge is an Open Source visual text file differencing and merging tool for Win32 platforms. It is highly useful for determing what has changed between project versions, and then merging changes between versions.
I have previously used to use windiff.exe to diff two files. This is or was part of the Windows Resource Kit. More recently I have used the freeware Context editor http://context.cx, which has a very good diff tool built in.
On a related note, Here’s a cool trick for finding registry differences between two machines: Export the subkey to a file for each machine and use a file diff tool to compare the differences. By default, the registry editor exports unicode, so either your diff tool has to support unicode, or you need to use the optional Win NT4/9x output format for your export.
Posted in Utilities, Open Source | Print | No Comments »