Skip to content

Commit f30e45a

Browse files
SQLTrace.ps1
Fixed the NETSH command string
1 parent 03fd549 commit f30e45a

File tree

2 files changed

+60
-57
lines changed

2 files changed

+60
-57
lines changed

SQLTrace/SQLTrace.ps1

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ LogRaw "
9191
/_______ /\_____\ \_/|_______ \|____| |__| (____ / \___ >\___ >
9292
\/ \__> \/ \/ \/ \/
9393
94-
SQLTrace.ps1 version 1.0.0090.0
94+
SQLTrace.ps1 version 1.0.0091.0
9595
by the Microsoft SQL Server Networking Team
9696
"
9797

@@ -559,40 +559,42 @@ Function StartNetworkMonitor
559559
## Create generic version of Cleanup Traces for BIDS, Network etc.
560560
Function StartCleanupETLTraceFiles
561561
{
562-
param
563-
(
564-
[string] $jobname,
565-
[string] $folder,
566-
[int] $numofFilesToKeep,
562+
param
563+
(
564+
[string] $jobname,
565+
[string] $folder,
566+
[int] $numofFilesToKeep,
567567
[int] $jobrunintervalMin
568-
)
568+
)
569569

570-
$job=Register-ScheduledJob -Name $jobname -scriptblock {
571-
Param($jobname,
570+
$job=Register-ScheduledJob -Name $jobname -scriptblock {
571+
Param($jobname,
572572
[string] $folder,
573573
[int] $numofFilesToKeep,
574574
[int] $jobrunintervalMin)
575-
gci -Path $folder -Recurse | where {(-not $_.PsIsContainer) -and ($_.name -notmatch "deleteme.etl") -and ($_.name -match ".etl") } | sort CreationTime -desc | select -skip $numofFilesToKeep | Remove-Item -Force @args
576-
} -ArgumentList $jobname, $folder, $numofFilesToKeep, $jobrunintervalMin
577-
$job.Options.RunElevated=$True
578-
$cleanupJob=New-JobTrigger -Once -At (get-date).AddSeconds(2) -RepetitionInterval (New-TimeSpan -Minutes $jobrunintervalMin) -RepeatIndefinitely ## -RepetitionDuration (New-TimeSpan -Minutes 20)
579-
Add-JobTrigger -Trigger $cleanupjob -Name $jobname
575+
gci -Path $folder -Recurse | where {(-not $_.PsIsContainer) -and ($_.name -notmatch "deleteme.etl") -and ($_.name -match ".etl") } | sort CreationTime -desc | select -skip $numofFilesToKeep | Remove-Item -Force @args
576+
} -ArgumentList $jobname, $folder, $numofFilesToKeep, $jobrunintervalMin
577+
$job.Options.RunElevated=$True
578+
$cleanupJob=New-JobTrigger -Once -At (get-date).AddSeconds(2) -RepetitionInterval (New-TimeSpan -Minutes $jobrunintervalMin) -RepeatIndefinitely ## -RepetitionDuration (New-TimeSpan -Minutes 20)
579+
Add-JobTrigger -Trigger $cleanupjob -Name $jobname
580580
}
581581

582582

583583
Function StopCleanupETLTraceFiles
584584
{
585-
param(
586-
$jobname
587-
)
588-
try
589-
{
590-
Stop-Job $jobname -ErrorAction SilentlyContinue
591-
Remove-Job $jobname -Force -ErrorAction SilentlyContinue
592-
Remove-JobTrigger $jobname -ErrorAction SilentlyContinue
593-
UnRegister-ScheduledJob -Name $jobname -Force -ErrorAction SilentlyContinue
594-
}
595-
catch { "Cleanup Job." }
585+
param
586+
(
587+
$jobname
588+
)
589+
590+
try
591+
{
592+
Stop-Job $jobname -ErrorAction SilentlyContinue
593+
Remove-Job $jobname -Force -ErrorAction SilentlyContinue
594+
Remove-JobTrigger $jobname -ErrorAction SilentlyContinue
595+
UnRegister-ScheduledJob -Name $jobname -Force -ErrorAction SilentlyContinue
596+
}
597+
catch { "Error stopping the Cleanup Job $jobname." }
596598
}
597599

598600

@@ -617,7 +619,7 @@ Function StartNetworkTraces
617619
$trucatePackets = ""
618620
if ($global:INISettings.TruncatePackets -eq "Yes") { $trucatePackets = "PACKETTRUNCATEBYTES=250"; }
619621

620-
$result = netsh trace start capture=yes maxsize=1 report=disabled TRACEFILE="$($global:LogFolderName)\NetworkTraces\deleteme.etl $truncatePackets" # Faster netsh shutdown clintonw #53
622+
$result = netsh trace start capture=yes maxsize=1 report=disabled TRACEFILE="$($global:LogFolderName)\NetworkTraces\deleteme.etl" $truncatePackets # Faster netsh shutdown clintonw #53
621623
LogInfo "NETSH: $result"
622624

623625
$result = logman start SQLTraceNDIS -p Microsoft-Windows-NDIS-PacketCapture -mode newfile -max 200 -o "$($global:LogFolderName)\NetworkTraces\nettrace%d.etl" -ets
@@ -647,8 +649,9 @@ Function StartAuthenticationTraces
647649
if($global:INISettings.AuthTrace -eq "Yes")
648650
{
649651

650-
if((Test-Path "$($global:LogFolderName)\Auth" -PathType Container) -eq $false){
651-
md "$($global:LogFolderName)\Auth" > $null
652+
if((Test-Path "$($global:LogFolderName)\Auth" -PathType Container) -eq $false)
653+
{
654+
md "$($global:LogFolderName)\Auth" > $null
652655
}
653656

654657
if($global:INISettings.Kerberos -eq "Yes")
@@ -657,13 +660,13 @@ Function StartAuthenticationTraces
657660

658661
# **Kerberos**
659662
$KerberosProviders = @(
660-
'{6B510852-3583-4e2d-AFFE-A67F9F223438}!0x7ffffff'
661-
'{60A7AB7A-BC57-43E9-B78A-A1D516577AE3}!0xffffff'
662-
'{FACB33C4-4513-4C38-AD1E-57C1F6828FC0}!0xffffffff'
663-
'{97A38277-13C0-4394-A0B2-2A70B465D64F}!0xff'
664-
'{8a4fc74e-b158-4fc1-a266-f7670c6aa75d}!0xffffffffffffffff'
665-
'{98E6CFCB-EE0A-41E0-A57B-622D4E1B30B1}!0xffffffffffffffff'
666-
)
663+
'{6B510852-3583-4e2d-AFFE-A67F9F223438}!0x7ffffff'
664+
'{60A7AB7A-BC57-43E9-B78A-A1D516577AE3}!0xffffff'
665+
'{FACB33C4-4513-4C38-AD1E-57C1F6828FC0}!0xffffffff'
666+
'{97A38277-13C0-4394-A0B2-2A70B465D64F}!0xff'
667+
'{8a4fc74e-b158-4fc1-a266-f7670c6aa75d}!0xffffffffffffffff'
668+
'{98E6CFCB-EE0A-41E0-A57B-622D4E1B30B1}!0xffffffffffffffff'
669+
)
667670

668671
# Kerberos Logging to SYSTEM event log in case this is a client
669672
reg add HKLM\SYSTEM\CurrentControlSet\Control\LSA\Kerberos\Parameters /v LogLevel /t REG_DWORD /d 1 /f
@@ -688,12 +691,12 @@ Function StartAuthenticationTraces
688691
LogInfo "Starting CredSSP/NTLM Traces..."
689692
# **Ntlm_CredSSP**
690693
$Ntlm_CredSSPProviders = @(
691-
'{5BBB6C18-AA45-49b1-A15F-085F7ED0AA90}!0x5ffDf'
692-
'{AC69AE5B-5B21-405F-8266-4424944A43E9}!0xffffffff'
693-
'{6165F3E2-AE38-45D4-9B23-6B4818758BD9}!0xffffffff'
694-
'{AC43300D-5FCC-4800-8E99-1BD3F85F0320}!0xffffffffffffffff'
695-
'{DAA6CAF5-6678-43f8-A6FE-B40EE096E06E}!0xffffffffffffffff'
696-
)
694+
'{5BBB6C18-AA45-49b1-A15F-085F7ED0AA90}!0x5ffDf'
695+
'{AC69AE5B-5B21-405F-8266-4424944A43E9}!0xffffffff'
696+
'{6165F3E2-AE38-45D4-9B23-6B4818758BD9}!0xffffffff'
697+
'{AC43300D-5FCC-4800-8E99-1BD3F85F0320}!0xffffffffffffffff'
698+
'{DAA6CAF5-6678-43f8-A6FE-B40EE096E06E}!0xffffffffffffffff'
699+
)
697700

698701
$result = logman create trace "SQLTraceNtlm_CredSSP" -o "$($global:LogFolderName)\Auth\Ntlm_CredSSP.etl" -ets
699702
LogInfo "NTLM_CredSSP: $result"
@@ -716,8 +719,8 @@ Function StartAuthenticationTraces
716719
LogInfo "Starting SSL Traces..."
717720
# **SSL**
718721
$SSLProviders = @(
719-
'{37D2C3CD-C5D4-4587-8531-4696C44244C8}!0x4000ffff'
720-
)
722+
'{37D2C3CD-C5D4-4587-8531-4696C44244C8}!0x4000ffff'
723+
)
721724

722725
# Start Logman SSL
723726
$result = logman start "SQLTraceSSL" -o "$($global:LogFolderName)\Auth\SSL.etl" -ets
@@ -746,20 +749,20 @@ Function StartAuthenticationTraces
746749

747750
# **LSA**
748751
$LSAProviders = @(
749-
'{D0B639E0-E650-4D1D-8F39-1580ADE72784}!0xC43EFF'
750-
'{169EC169-5B77-4A3E-9DB6-441799D5CACB}!0xffffff'
751-
'{DAA76F6A-2D11-4399-A646-1D62B7380F15}!0xffffff'
752-
'{366B218A-A5AA-4096-8131-0BDAFCC90E93}!0xfffffff'
753-
'{4D9DFB91-4337-465A-A8B5-05A27D930D48}!0xff'
754-
'{7FDD167C-79E5-4403-8C84-B7C0BB9923A1}!0xFFF'
755-
'{CA030134-54CD-4130-9177-DAE76A3C5791}!0xfffffff'
756-
'{5a5e5c0d-0be0-4f99-b57e-9b368dd2c76e}!0xffffffffffffffff'
757-
'{2D45EC97-EF01-4D4F-B9ED-EE3F4D3C11F3}!0xffffffffffffffff'
758-
'{C00D6865-9D89-47F1-8ACB-7777D43AC2B9}!0xffffffffffffffff'
759-
'{7C9FCA9A-EBF7-43FA-A10A-9E2BD242EDE6}!0xffffffffffffffff'
760-
'{794FE30E-A052-4B53-8E29-C49EF3FC8CBE}!0xffffffffffffffff'
761-
'{ba634d53-0db8-55c4-d406-5c57a9dd0264}!0xffffffffffffffff'
762-
)
752+
'{D0B639E0-E650-4D1D-8F39-1580ADE72784}!0xC43EFF'
753+
'{169EC169-5B77-4A3E-9DB6-441799D5CACB}!0xffffff'
754+
'{DAA76F6A-2D11-4399-A646-1D62B7380F15}!0xffffff'
755+
'{366B218A-A5AA-4096-8131-0BDAFCC90E93}!0xfffffff'
756+
'{4D9DFB91-4337-465A-A8B5-05A27D930D48}!0xff'
757+
'{7FDD167C-79E5-4403-8C84-B7C0BB9923A1}!0xFFF'
758+
'{CA030134-54CD-4130-9177-DAE76A3C5791}!0xfffffff'
759+
'{5a5e5c0d-0be0-4f99-b57e-9b368dd2c76e}!0xffffffffffffffff'
760+
'{2D45EC97-EF01-4D4F-B9ED-EE3F4D3C11F3}!0xffffffffffffffff'
761+
'{C00D6865-9D89-47F1-8ACB-7777D43AC2B9}!0xffffffffffffffff'
762+
'{7C9FCA9A-EBF7-43FA-A10A-9E2BD242EDE6}!0xffffffffffffffff'
763+
'{794FE30E-A052-4B53-8E29-C49EF3FC8CBE}!0xffffffffffffffff'
764+
'{ba634d53-0db8-55c4-d406-5c57a9dd0264}!0xffffffffffffffff'
765+
)
763766

764767
#Registry LSA
765768
reg add HKLM\SYSTEM\CurrentControlSet\Control\LSA /v SPMInfoLevel /t REG_DWORD /d 0xC43EFF /f 2>&1
6.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)