Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Unable to automate the Script Expand / Collapse
Author
Message
Posted Thursday, May 16, 2013 3:04 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 10:02 PM
Points: 901, Visits: 1,464
The below script provides the list of trace files available to the location : D:\Trace

$fileEntries = [IO.Directory]::GetFiles("D:\Trace\");
foreach($fileName in $fileEntries)
{
[Console]::WriteLine($fileName);
}

I want to pass each trace files to the below block to change the trace files compatible to SQL 2008 R2 format.

# Enter your filename here
$fileName = "D:\Trace\XXXX.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()

Kindly assist....


Thanks.
Post #1453793
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse