How to remotely register static ETW manifest as part of website deployment?

I am doing an experimental effort to use the new EventSource (Microsoft.Diagnostics.Tracing.EventSource from nuget) and its new ETW feed support for writing to the Windows event log. The code is in place, and it is correctly recorded in the event log of my workstations. I'm excited.

Now comes the hard part. An application that uses this feature is a web service, and we deploy it using webdeploy as part of the build-deploy-test system. Since the use of ETW channels requires static registration of the provider’s manifestations through wevtutil.exe. The EventSource documentation says that this is best done as part of the installer, but it is a bit like the webdeploy capabilities.

Our goal is that we can automatically remove the resident resident on the target server just before the webdeploy package is executed, and then import the new manifest after the webdeploy synchronization is complete. We are not tuned for this, but it seems the most reasonable way.

For this reason, it seems like maybe this is something that might allow powershell remote control, but this is not an area that I know a lot about.

Has anyone done something like this? Is there a better or easier way?

+4
source share
1 answer

. A) PowerShell, , PowerShell 2.0 . B) script, , , , , .

:

Set-ExecutionPolicy RemoteSigned
Enable-PSRemoting -Force

- script:

# these two paths assume these files have been copied to the remote computer and to a directory
# in which the service account has privileges to read i.e. not under a userprofile dir.
$etwDllPath = c:\somepath\myassembly.mysourcename.etwManifest.dll
$etwManPath = c:\somepath\myassembly.mysourcename.etwManifest.man
$s = New-PSSession -ComputerName <remoteComputerName>
Invoke-Command -Session $s {param($man) wevtutil.exe um $man} -arg $etwManPath
Invoke-Command -Session $s {param($man,$dll) wevutil.exe im $man /rf:$dll /mf:$dll} -arg $etwManPath, $etwDllPath
Remove-PSSession $s

, . .: -)

+3

Source: https://habr.com/ru/post/1525128/


All Articles