File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,10 @@ function Invoke-DiscoveryProtocolCapture {
148148 [String ]$Type ,
149149
150150 [Parameter ()]
151- [switch ]$NoCleanup
151+ [switch ]$NoCleanup ,
152+
153+ [Parameter ()]
154+ [switch ]$Force
152155 )
153156
154157 begin {
@@ -195,6 +198,16 @@ function Invoke-DiscoveryProtocolCapture {
195198
196199 if ($Adapter ) {
197200 $SessionName = ' Capture-{0}' -f (Get-Date ).ToString(' s' )
201+
202+ if ($Force.IsPresent ) {
203+ Get-NetEventSession - CimSession $CimSession | ForEach-Object {
204+ if ($_.SessionStatus -eq ' Running' ) {
205+ $_ | Stop-NetEventSession - CimSession $CimSession
206+ }
207+ $_ | Remove-NetEventSession - CimSession $CimSession
208+ }
209+ }
210+
198211 New-NetEventSession - Name $SessionName - LocalFilePath $ETLFilePath - CaptureMode SaveToFile - CimSession $CimSession | Out-Null
199212
200213 $LinkLayerAddress = switch ($Type ) {
You can’t perform that action at this time.
0 commit comments