In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The WMI consumers of the monitoring types introduced in this paper are mainly CommandLineEventConsumer and LogFileEventConsumer.
For more information, see the following link:
CommandLineEventConsumer
LogFileEventConsumer
Let's take the PowerShell script as an example to show how to create WMI event monitoring
1. LogFileEventConsumer example
1. Create an EventFilter to filter events that need to be monitored
${EventNamespace} = "the event namespace which is to be monitored"
${QueryLanguage} = 'WQL'
${Namespace} = "root\ subscription"
${ComputerName} = "."
${Query} = "WQL Query Statement"
${Name} = "EventFilter Name"
${NewFilter} = ([wmiclass] "\ ${ComputerName}\ ${Namespace}: _ _ EventFilter") .CreateInstance ()
${NewFilter}. {QueryLanguage} = ${QueryLanguage}
${NewFilter}. {Query} = ${Query}
${NewFilter}. {EventNamespace} = ${EventNamespace}
${NewFilter}. {Name} = ${Name}
$result = $NewFilter.Put ()
2. Create a Consumer and trigger the corresponding action
${Text} = 'the text which is to be logged'
${FileName} = "FileName"
${IsUnicode} = "true"
${ComputerName} = "."
${Name} = "EventConsumer Name"
${NewConsumer} = ([wmiclass] "\ ${ComputerName}\ root\ subscription:LogFileEventConsumer") .CreateInstance ()
${NewConsumer}. {Name} = ${Name}
${NewConsumer}. {FileName} = ${FileName}
${NewConsumer}. {IsUnicode} = ${IsUnicode}
${NewConsumer}. {Text} = ${Text}
$NewConsumer.Put ()
3. Create Binding, bind EventFilter and Cousumer, and trigger the action immediately when the event is captured.
${Namespace} = "root\ subscription"
${ComputerName} = "."
${NewBinding} = ([wmiclass] "\ ${ComputerName}\ ${Namespace}: _ _ FilterToConsumerBinding") .CreateInstance ()
${NewBinding} .filter = "\\ ${ComputerName}\ ROOT\ Subscription:__EventFilter.Name= `" EventFilter name ""
${NewBinding}. {Consumer} = "\\ ${ComputerName}\ ROOT\ Subscription:LogFileEventConsumer.Name= `" EventConsumer name ""
${NewBinding}. {MaintainSecurityContext} = ${FALSE}
${NewBinding}. {SlowDownProviders} = ${FALSE}
$NewBinding.Put ()
II. CommandLineEventConsumer example
1. Create an EventFilter to filter events that need to be monitored
${EventNamespace} = "the event namespace which is to be monitored"
${QueryLanguage} = 'WQL'
${Namespace} = "root\ subscription"
${ComputerName} = "."
${Query} = "WQL Query Statement"
${Name} = "EventFilter Name"
${NewFilter} = ([wmiclass] "\ ${ComputerName}\ ${Namespace}: _ _ EventFilter") .CreateInstance ()
${NewFilter}. {QueryLanguage} = ${QueryLanguage}
${NewFilter}. {Query} = ${Query}
${NewFilter}. {EventNamespace} = ${EventNamespace}
${NewFilter}. {Name} = ${Name}
$result = $NewFilter.Put ()
2. Create a Consumer and trigger the corresponding action (to execute the PowerShell command behavior example)
${Namespace} = "root\ subscription"
${ComputerName} = "."
${Name} = "EventConsumer Name"
$ExecutablePath= "c:\ xxx\ xxx\ powershell.exe"
$CommandLineTemplate= "powershell.exe-File D:\ xxx\ xxx.ps1"
${NewConsumer} = ([wmiclass] "\ ${ComputerName}\ ${Namespace}: CommandLineEventConsumer") .CreateInstance ()
${NewConsumer}. {CommandLineTemplate} = ${CommandLineTemplate}
${NewConsumer}. {ExecutablePath} = ${ExecutablePath}
${NewConsumer}. {name} = ${Name}
$NewConsumer.Put ()
3. Create Binding, bind EventFilter and Cousumer, and trigger the action immediately when the event is captured.
${Namespace} = "root\ subscription"
${ComputerName} = "."
${NewBinding} = ([wmiclass] "\ ${ComputerName}\ ${Namespace}: _ _ FilterToConsumerBinding") .CreateInstance ()
${NewBinding} .filter = "\\ ${ComputerName}\ ROOT\ Subscription:__EventFilter.Name= `" EventFilter name ""
${NewBinding}. {Consumer} = "\\ ${ComputerName}\ ROOT\ Subscription:CommandLineEventConsumer.Name= `" EventConsumer name ""
${NewBinding}. {MaintainSecurityContext} = ${FALSE}
${NewBinding}. {SlowDownProviders} = ${FALSE}
$NewBinding.Put ()
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.