我正在创建一个新的 EventLog EventSource,并使用我自己的自定义类别集。
我目前在 C# 代码中使用以下代码执行此操作:
var eventSourceData = new EventSourceCreationData(sourceName, logName)
{
CategoryCount = AllCategories.Count(),
CategoryResourceFile = resourceFilePath,
ParameterResourceFile = resourceFilePath,
MessageResourceFile = resourceFilePath
};
EventLog.CreateEventSource(eventSourceData);
我现在已将其转换为这样的 powershell 脚本:
New-eventlog -logname $Log -ComputerName $ComputerName -Source $Source -CategoryResourceFile $categoryDllPath -MessageResourceFile $categoryDllPath -ErrorVariable Err -CategoryCount 20
Notr -CategoryCount 20最后,我的脚本在这个参数上失败,说它不是一个有效的参数。(这似乎不是)
所以我的问题是,使用 Powershell 如何提供 CategoryCount 以便日志记录正常工作?
非常感谢。
错误信息是A parameter cannot be found that matches parameter name 'CategoryCount'.