C# EventLogSession Local Admin

matitdob 21 Reputation points
2021-04-08T10:23:20.01+00:00

I have a problem how to use the code below for the admin of the local remote computer. Typing ".", "" Or "computer name" as domain doesn't help. The omission results in a syntax error.

EventLogSession session = new EventLogSession(
"ComputerName", // Remote Computer
"Domain", //Domain
"Admin", // Username
pw,
SessionAuthentication.Default);

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,234 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,611 Reputation points
    2021-04-09T07:04:10.413+00:00

    Hi matitdob-1938,
    If you query events from a remote computer, you need to specify the name and domain of the remote computer, as well as the user name and password used to connect to the remote computer. Instead of Typing ".", "" Or "computer name" as Domain.
    More details you can refer to this document.
    In addition, you need to be ensure that the specified user has local administrator rights on the PC queried by EventLogSession.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments