Advertisement
Guest User

Trace-GeoLocation.ps1

a guest
Jul 8th, 2024
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. $ETLLog = 'c:\LocationService.etl'
  2.  
  3. # Stop the lfsvc service
  4. $SC_lfsvc = Get-Service -Name lfsvc
  5.  
  6. if ($SC_lfsvc.Status -eq 'Running') {
  7. Write-Host "Stopping - lfsvc"
  8. $SC_lfsvc.Stop()
  9.  
  10. # Wait until the service is stopped
  11. do {
  12. $SC_lfsvc.Refresh()
  13. Start-Sleep -Seconds 1
  14. } while ($SC_lfsvc.Status -ne 'Stopped')
  15.  
  16. Write-Host "lfsvc has stopped."
  17. }
  18.  
  19.  
  20. # Delete files from lfsvc cache
  21. If (Test-Path $ETLLog ) { Remove-Item -path $ETLLog -Force }
  22. Remove-Item -Path "C:\ProgramData\Microsoft\Windows\lfsvc\cache\*" -Force -Recurse
  23.  
  24. # Create ETW session.
  25. Start-EtwTraceSession -Name LocationService -LocalFilePath $ETLLog -RealTime
  26.  
  27. # Add provider(s) to session.
  28. $Guid = "4D13548F-C7B8-4174-BB7A-D7F64BF22D29"
  29. Add-EtwTraceProvider -SessionName LocationService -Guid "{$Guid}"
  30.  
  31. # Start the lfsvc service
  32. if ($SC_lfsvc.Status -ne 'Running') {
  33. Write-Host "Starting - lfsvc"
  34. $SC_lfsvc.Start()
  35.  
  36. # Wait until the service is stopped
  37. do {
  38. $SC_lfsvc.Refresh()
  39. Start-Sleep -Seconds 1
  40. } while ($SC_lfsvc.Status -ne 'Running')
  41.  
  42. Write-Host "lfsvc has started."
  43. }
  44.  
  45. # Wait for *.tile file to appear in lfsvc cache
  46. do { Start-Sleep -Seconds 5 } until (Test-Path -Path "C:\ProgramData\Microsoft\Windows\lfsvc\cache\*.tile")
  47.  
  48. Stop-EtwTraceSession -Name LocationService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement