wecutil

使你能够创建和管理从远程计算机转发的事件的订阅。 远程计算机必须支持 WS-Management 协议。

Important

如果收到消息“RPC 服务器不可用?尝试运行 wecutil 时,需要启动 Windows 事件收集器服务(wecsvc)。 若要启动 wecsvc,请在提升的命令提示符下键入 net start wecsvc

Syntax

wecutil [{es | enum-subscription}] [{gs | get-subscription} <Subid> [/f:<Format>] [/uni:<Unicode>]] [{gr | get-subscriptionruntimestatus} <Subid> [<Eventsource> …]] [{ss | set-subscription} [<Subid> [/e:[<Subenabled>]] [/esa:<Address>] [/ese:[<Srcenabled>]] [/aes] [/res] [/un:<Username>] [/up:<Password>] [/d:<Desc>] [/uri:<Uri>] [/cm:<Configmode>] [/ex:<Expires>] [/q:<Query>] [/dia:<Dialect>] [/tn:<Transportname>] [/tp:<Transportport>] [/dm:<Deliverymode>] [/dmi:<Deliverymax>] [/dmlt:<Deliverytime>] [/hi:<Heartbeat>] [/cf:<Content>] [/l:<Locale>] [/ree:[<Readexist>]] [/lf:<Logfile>] [/pn:<Publishername>] [/essp:<Enableport>] [/hn:<Hostname>] [/ct:<Type>]] [/c:<Configfile> [/cun:<Username> /cup:<Password>]]] [{cs | create-subscription} <Configfile> [/cun:<Username> /cup:<Password>]] [{ds | delete-subscription} <Subid>] [{rs | retry-subscription} <Subid> [<Eventsource>…]] [{qc | quick-config} [/q:[<quiet>]]]

Parameters

Parameter Description
{es | enum-subscription} 显示存在的所有远程事件订阅的名称。
{gs | get-subscription} <Subid> [/f:<Format>] [/uni:<Unicode>] 显示远程订阅配置信息。 <Subid> 是唯一标识订阅的字符串。 它与 XML 配置文件的标记中指定的 <SubscriptionId> 字符串相同,该文件用于创建订阅。
{gr | get-subscriptionruntimestatus} <Subid> [<Eventsource> …] 显示订阅的运行时状态。 <Subid> 是唯一标识订阅的字符串。 它与 XML 配置文件的标记中指定的 <SubscriptionId> 字符串相同,该文件用于创建订阅。 <Eventsource> 是一个字符串,用于标识充当事件源的计算机。 它应该是完全限定的域名、NetBIOS 名称或 IP 地址。
{ss | set-subscription} <Subid> [/e:[<Subenabled>]] [/esa:<Address>] [/ese:[<Srcenabled>]] [/aes] [/res] [/un:<Username>] [/up:<Password>] [/d:<Desc>] [/uri:<Uri>] [/cm:<Configmode>] [/ex:<Expires>] [/q:<Query>] [/dia:<Dialect>] [/tn:<Transportname>] [/tp:<Transportport>] [/dm:<Deliverymode>] [/dmi:<Deliverymax>] [/dmlt:<Deliverytime>] [/hi:<Heartbeat>] [/cf:<Content>] [/l:<Locale>] [/ree:[<Readexist>]] [/lf:<Logfile>] [/pn:<Publishername>] [/essp:<Enableport>] [/hn:<Hostname>] [/ct:<Type>]
OR
{ss | set-subscription /c:<Configfile> [/cun:<Comusername> /cup:<Compassword>]
更改订阅配置。 可以指定订阅 ID 和更改订阅参数的适当选项,也可以指定 XML 配置文件来更改订阅参数。
{cs | create-subscription} <Configfile> [/cun:<Username> /cup:<Password>] 创建远程订阅。 <Configfile> 指定包含订阅配置的 XML 文件的路径。 路径可以是绝对路径,也可以是相对于当前目录的。
{ds | delete-subscription} <Subid> 删除订阅,并从所有将事件传递到订阅事件日志的事件源取消订阅。 不会删除已接收和记录的任何事件。 <Subid> 是唯一标识订阅的字符串。 它与 XML 配置文件的标记中指定的 <SubscriptionId> 字符串相同,该文件用于创建订阅。
{rs | retry-subscription} <Subid> [<Eventsource>…] 重试以建立连接并将远程订阅请求发送到非活动订阅。 尝试重新激活所有事件源或指定的事件源。 不会重试禁用的源。 <Subid> 是唯一标识订阅的字符串。 它与 XML 配置文件的标记中指定的 <SubscriptionId> 字符串相同,该文件用于创建订阅。 <Eventsource> 是一个字符串,用于标识充当事件源的计算机。 它应该是完全限定的域名、NetBIOS 名称或 IP 地址。
{qc | quick-config} [/q:[<Quiet>]] 配置 Windows 事件收集器服务,以确保可以通过重新启动创建和维持订阅。 这包括以下步骤:
  1. 如果禁用 ForwardedEvents 通道,请启用通道。
  2. 将 Windows 事件收集器服务设置为延迟启动。
  3. 如果 Windows 事件收集器服务未运行,请启动它。

选项

Option Description
/f:<Format> 指定显示的信息的格式。 <Format> 可以是 XML 或 Terse。 If it's XML, the output is displayed in XML format. If it's Terse, the output is displayed in name-value pairs. The default is Terse.
/c:<Configfile> 指定包含订阅配置的 XML 文件的路径。 路径可以是绝对路径,也可以是相对于当前目录的。 This option can only be used with the /cun and /cup options and is mutually exclusive with all other options.
/e:[<Subenabled>] 启用或禁用订阅。 <Subenabled> 可以为 true 或 false。 The default value of this option is true.
/esa:<Address> 指定事件源的地址。 <Address> 是一个字符串,其中包含完全限定的域名、NetBIOS 名称或 IP 地址,用于标识充当事件源的计算机。 This option should be used with the /ese, /aes, /res, or /un and /up options.
/ese:[<Srcenabled>] 启用或禁用事件源。 <Srcenabled> 可以为 true 或 false。 This option is allowed only if the /esa option is specified. The default value of this option is true.
/aes Adds the event source that is specified by the /esa option if it is not already a part of the subscription. If the address specified by the /esa option is already a part of the subscription, an error is reported. This option is only allowed if the /esa option is specified.
/res Removes the event source that is specified by the /esa option if it is already a part of the subscription. If the address specified by the /esa option is not a part of the subscription, an error is reported. This option is only allowed if /esa option is specified.
/un:<Username> Specifies the user credential to use with the event source specified by the /esa option. This option is only allowed if the /esa option is specified.
/up:<Password> 指定与用户凭据对应的密码。 This option is only allowed if the /un option is specified.
/d:<Desc> 提供订阅的说明。
/uri:<Uri> 指定订阅使用的事件的类型。 <Uri> 包含一个 URI 字符串,该字符串与事件源计算机的地址相结合,用于唯一标识事件的源。 URI 字符串用于订阅中的所有事件源地址。
/cm:<Configmode> 设置配置模式。 <Configmode> can be one of the following strings: Normal, Custom, MinLatency or MinBandwidth. The Normal, MinLatency, and MinBandwidth modes set delivery mode, delivery max items, heartbeat interval, and delivery max latency time. The /dm, /dmi, /hi or /dmlt options may only be specified if the configuration mode is set to Custom.
/ex:<Expires> 设置订阅过期的时间。 <Expires> should be defined in standard XML or ISO8601 date-time format: yyyy-MM-ddThh:mm:ss[.sss][Z], where T is the time separator and Z indicates UTC time.
/q:<Query> 指定订阅的查询字符串。 对于不同的 URI 值,其格式 <Query> 可能有所不同,适用于订阅中的所有源。
/dia:<Dialect> 定义查询字符串使用的方言。
/tn:<Transportname> 指定用于连接到远程事件源的传输的名称。
/tp:<Transportport> 设置连接到远程事件源时传输使用的端口号。
/dm:<Deliverymode> 指定传递模式。 <Deliverymode> 可以是拉取或推送。 This option is only valid if the /cm option is set to Custom.
/dmi:<Deliverymax> 设置批量传递的最大项目数。 This option is only valid if /cm is set to Custom.
/dmlt:<Deliverytime> 设置传送一批事件的最大延迟。 <Deliverytime> 是毫秒数。 This option is only valid if /cm is set to Custom.
/hi:<Heartbeat> 定义检测信号间隔。 <Heartbeat> 是毫秒数。 This option is only valid if /cm is set to Custom.
/cf:<Content> 指定返回的事件的格式。 <Content> 可以是事件或 RenderedText。 When the value is RenderedText, the events are returned with the localized strings (such as event description) attached to the event. The default value is RenderedText.
/l:<Locale> 指定用于以 RenderedText 格式传递本地化字符串的区域设置。 <Locale> 是语言和国家/地区标识符,例如 EN-us。 This option is only valid if the /cf option is set to RenderedText.
/ree:[<Readexist>] 标识为订阅传递的事件。 <Readexist> 可以为 true 或 false。 如果为 <Readexist> true,则从订阅事件源读取所有现有事件。 如果为 <Readexist> false,则只传递未来(到达)事件。 The default value is true for a /ree option without a value. If no /ree option is specified, the default value is false.
/lf:<Logfile> 指定用于存储从事件源接收的事件的本地事件日志。
/pn:<Publishername> 指定发布者名称。 It must be a publisher that owns or imports the log specified by the /lf option.
/essp:<Enableport> 指定必须将端口号追加到远程服务的服务主体名称。 <Enableport> 可以为 true 或 false。 如果为 true,则追加 <Enableport> 端口号。 追加端口号时,可能需要一些配置来阻止访问事件源。
/hn:<Hostname> 指定本地计算机的 DNS 名称。 远程事件源使用此名称来回推事件,并且只能用于推送订阅。
/ct:<Type> 设置远程源访问的凭据类型。 <Type> should be one of the following values: default, negotiate, digest, basic or localmachine. The default value is default.
/cun:<Comusername> 设置要用于没有其自己的用户凭据的事件源的共享用户凭据。 If this option is specified with the /c option, UserName and UserPassword settings for individual event sources from the configuration file are ignored. If you want to use a different credential for a specific event source, you should override this value by specifying the /un and /up options for a specific event source on the command line of another ss command.
/cup:<Compassword> 设置共享用户凭据的用户密码。 如果 <Compassword> 设置为 * (星号),将从控制台读取密码。 This option is only valid when the /cun option is specified.
/q:[<Quiet>] 指定配置过程是否提示进行确认。 <Quiet> 可以为 true 或 false。 如果 <Quiet> 为 true,则配置过程不会提示确认。 The default value of this option is false.

Examples

若要显示配置文件的内容,请键入:

<Subscription xmlns=https://schemas.microsoft.com/2006/03/windows/events/subscription>
<Uri>https://schemas.microsoft.com/wbem/wsman/1/windows/EventLog</Uri>
<!-- Use Normal (default), Custom, MinLatency, MinBandwidth -->
<ConfigurationMode>Normal</ConfigurationMode>
  <Description>Forward Sample Subscription</Description>
  <SubscriptionId>SampleSubscription</SubscriptionId>
  <Query><![CDATA[
    <QueryList>
      <Query Path=Application>
        <Select>*</Select>
      </Query>
    </QueryList>]]
  </Query>
<EventSources>
  <EventSource Enabled=true>
    <Address>mySource.myDomain.com</Address>
    <UserName>myUserName</UserName>
    <Password>*</Password>
  </EventSource>
</EventSources>
<CredentialsType>Default</CredentialsType>
<Locale Language=EN-US></Locale>
</Subscription>

To view the output configuration information for a subscription named sub1, type:

wecutil gs sub1

Example output:

EventSource[0]:
Address: localhost
Enabled: true
Description: Subscription 1
Uri: wsman:microsoft/logrecord/sel
DeliveryMode: pull
DeliveryMaxSize: 16000
DeliveryMaxItems: 15
DeliveryMaxLatencyTime: 1000
HeartbeatInterval: 10000
Locale:
ContentFormat: renderedtext
LogFile: HardwareEvents

若要显示名为 sub1 的订阅的运行时状态,请键入:

wecutil gr sub1

To update the subscription configuration named sub1 from a new XML file called WsSelRg2.xml, type:

wecutil ss sub1 /c:%Windir%system32WsSelRg2.xml

To update the subscription configuration named sub2 with multiple parameters, type:

wecutil ss sub2 /esa:myComputer /ese /un:uname /up:* /cm:Normal

To delete a subscription named sub1, type:

wecutil ds sub1