forked from ktaranov/sqlserver-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvert_trc_to_2008r2.ps1
More file actions
33 lines (27 loc) · 1.02 KB
/
Copy pathConvert_trc_to_2008r2.ps1
File metadata and controls
33 lines (27 loc) · 1.02 KB
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
31
32
33
#requires -version 2.0
<#
.SYNOPSIS
Changes the version information in the header of a SQL Server trace
.DESCRIPTION
Author: Gianluca Sartori - @spaghettidba
Create date: 2012-11-07
https://spaghettidba.com/2012/11/08/more-on-converting-trace-files/
.PARAMETER fileName
Trace file name
#>
## =============================================
## Author: Gianluca Sartori - @spaghettidba
## Create date: 2012-11-07
## Description: Changes the version information
## in the header of a SQL Server trace
## =============================================
$fileName = "somefile.trc"
# The version information we want to write: 0x0A = 10 = SQLServer 2008
[Byte[]] $versionData = 0x0A
# The offset of the version information in the file
$offset = 390
[System.IO.FileMode] $open = [System.IO.FileMode]::OpenOrCreate
$stream = New-Object System.IO.FileStream -ArgumentList $fileName, $open
$stream.Seek($offset, [System.IO.SeekOrigin]::Begin);
$stream.Write($versionData, 0, $versionData.Length);
$stream.Close()