Skip to content

Commit d62cc3e

Browse files
authored
Add packet capture and max size support to Trace-PlayFabParty helper script (#47)
1 parent 19fc15c commit d62cc3e

File tree

1 file changed

+61
-3
lines changed

1 file changed

+61
-3
lines changed

TraceScripts/Trace-PlayFabParty.ps1

+61-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,23 @@ param(
2121

2222
# Whether to include verbose transport entries in the trace file.
2323
# Defaults to false if not specified.
24-
[switch]$IncludeTransport
24+
[switch]$IncludeTransport,
25+
26+
# Whether to include a raw packet capture and Windows OS networking stack
27+
# entries in the trace file.
28+
# NOTE: Using this switch may record networking activity on the device
29+
# beyond that which directly involves PlayFab Party, and is not recommended
30+
# unless specifically requested for additional support.
31+
# Defaults to false if not specified.
32+
[switch]$IncludePackets,
33+
34+
# Sets a maximum output file size, in megabytes, for long-running traces of
35+
# scenarios that can't be narrowed another way. A circular buffer is used,
36+
# where only the most recent entries are kept if the output file would
37+
# exceed the maximum.
38+
# If not specified, this parameter defaults to 0, which does not constrain
39+
# trace output file size.
40+
[int]$MaxSizeInMB
2541
)
2642

2743
if (($OutputFile -ne $null) -and ($OutputFile -ne ""))
@@ -70,7 +86,39 @@ else
7086
{
7187
$xrnWppProvider = ""
7288
}
73-
$providersString = @($playfabPartyWppProvider, $xnupWppProvider, $xrnWppProvider) -Join " "
89+
if ($IncludePackets)
90+
{
91+
Write-Warning "A packet capture was requested with this trace. The resulting output file may therefore record Internet/networking activity on this device beyond just PlayFab Party communication, such as potentially sensitive web browser or private local network connections."
92+
Write-Host ""
93+
Write-Host "Please close all unneeded background applications, and never store the resulting output file in an insecure location."
94+
Write-Host ""
95+
Write-Host "Be aware that providing the output file to Microsoft support agents may allow them visibility of such networking activities. However only the minimum information required for PlayFab Party support will be used, and no parts will ever be shared with anyone for any reason. All records will be deleted once the support issue has been resolved."
96+
Write-Host ""
97+
Read-Host "To abort, press Control-C. Otherwise, press 'Enter'"
98+
$captureString = "capture=yes"
99+
# TCP/IP
100+
$osNetworkingProviders = "provider={2F07E2EE-15DB-40F1-90EF-9D7BA282188A} keywords=0xFFFFFFFFFFFFFFFF level=5"
101+
# AFD
102+
$osNetworkingProviders += " provider={E53C6823-7BB8-44BB-90DC-3F86090D48A6} keywords=0xFFFFFFFFFFFFFFFF level=5"
103+
# BFE
104+
$osNetworkingProviders += " provider={106B464A-8043-46B1-8CB8-E92A0CD7A560} keywords=0xFFFFFFFFFFFFFFFF level=5"
105+
# fwpkclnt
106+
$osNetworkingProviders += " provider={AD33fA19-F2D2-46D1-8F4C-E3C3087E45AD} keywords=0xFFFFFFFFFFFFFFFF level=5"
107+
# fwpuclnt
108+
$osNetworkingProviders += " provider={5A1600D2-68E5-4DE7-BCF4-1C2D215FE0FE} keywords=0xFFFFFFFFFFFFFFFF level=5"
109+
# WFP
110+
$osNetworkingProviders += " provider={0C478C5B-0351-41B1-8C58-4A6737DA32E3} keywords=0xFFFFFFFFFFFFFFFF level=5"
111+
# DNS
112+
$osNetworkingProviders += " provider={1C95126E-7EEA-49A9-A3FE-A378B03DDB4D} keywords=0xFFFFFFFFFFFFFFFF level=5"
113+
# WS NR
114+
$osNetworkingProviders += " provider={B923F87A-B069-42B5-BD32-35623ABA1C48} keywords=0xFFFFFFFFFFFFFFFF level=5"
115+
}
116+
else
117+
{
118+
$captureString = "capture=no"
119+
$osNetworkingProviders = ""
120+
}
121+
$providersString = @($playfabPartyWppProvider, $xnupWppProvider, $xrnWppProvider, $osNetworkingProviders) -Join " "
74122

75123
# Attempt to determine if the netsh trace start command supports the
76124
# 'bufferSize' parameter on this system by looking for the "bufferSize=" string
@@ -85,7 +133,17 @@ else
85133
$bufferSizeString = ""
86134
}
87135

88-
$netshStartCmd = "netsh trace start $bufferSizeString overwrite=no tracefile=`"$traceFileName`" report=disable $providersString"
136+
# Configure the appropriate output file size limit and mode.
137+
if (($MaxSizeInMB -ne $null) -and ($MaxSizeInMB -gt 0))
138+
{
139+
$maxSizeString = "maxSize=$MaxSizeInMB fileMode=circular"
140+
}
141+
else
142+
{
143+
$maxSizeString = "maxSize=0 fileMode=single"
144+
}
145+
146+
$netshStartCmd = "netsh trace start $bufferSizeString overwrite=no tracefile=`"$traceFileName`" $captureString report=disable $maxSizeString $providersString"
89147

90148
Write-Host $netshStartCmd
91149
cmd /c $netshStartCmd

0 commit comments

Comments
 (0)