Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ETLLog = 'c:\LocationService.etl'
- # Stop the lfsvc service
- $SC_lfsvc = Get-Service -Name lfsvc
- if ($SC_lfsvc.Status -eq 'Running') {
- Write-Host "Stopping - lfsvc"
- $SC_lfsvc.Stop()
- # Wait until the service is stopped
- do {
- $SC_lfsvc.Refresh()
- Start-Sleep -Seconds 1
- } while ($SC_lfsvc.Status -ne 'Stopped')
- Write-Host "lfsvc has stopped."
- }
- # Delete files from lfsvc cache
- If (Test-Path $ETLLog ) { Remove-Item -path $ETLLog -Force }
- Remove-Item -Path "C:\ProgramData\Microsoft\Windows\lfsvc\cache\*" -Force -Recurse
- # Create ETW session.
- Start-EtwTraceSession -Name LocationService -LocalFilePath $ETLLog -RealTime
- # Add provider(s) to session.
- $Guid = "4D13548F-C7B8-4174-BB7A-D7F64BF22D29"
- Add-EtwTraceProvider -SessionName LocationService -Guid "{$Guid}"
- # Start the lfsvc service
- if ($SC_lfsvc.Status -ne 'Running') {
- Write-Host "Starting - lfsvc"
- $SC_lfsvc.Start()
- # Wait until the service is stopped
- do {
- $SC_lfsvc.Refresh()
- Start-Sleep -Seconds 1
- } while ($SC_lfsvc.Status -ne 'Running')
- Write-Host "lfsvc has started."
- }
- # Wait for *.tile file to appear in lfsvc cache
- do { Start-Sleep -Seconds 5 } until (Test-Path -Path "C:\ProgramData\Microsoft\Windows\lfsvc\cache\*.tile")
- Stop-EtwTraceSession -Name LocationService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement