Unable to automate the Script

  • 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.

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply