powershell - PowerShell - 展开组对象
问题描述
我想扩展一个 PowerShell 组对象。但只有第一个对象。
Get-EventLog -Logname system -EntryType "Error" | Group-Object 'InstanceID' | Select-Object Count, Name, @{Name="Message";Expression={$_.Group.Message[0]}} | Format-Table -Wrap
结果是:
Count Name Message
----- ---- -------
161 17 ESIF(8.7.10200.12510) TYPE: ERROR MODULE: DPTF TIME 81546445 ms
这可以。但如果只有 1 个事件计数:
Count Name Message
----- ---- -------
1 8193 V
他们只得到了第一个字符。
我怎样才能获得完整的第一个字符串?有什么建议么?
谢谢。
解决方案
您可以使用Select-Object
选择第一条消息。
Get-EventLog -Logname system -EntryType "Error" |
Group-Object 'InstanceID' | Select-Object Count, Name,
@{Name="Message";Expression={$_.Group.Message | select -first 1}} |
Format-Table -Wrap
我的示例输出与您的示例输出的唯一区别是整个消息是针对单个计数条目收集的,而不仅仅是第一个字符。
Count Name Message
----- ---- -------
8 15 The device driver for the Trusted Platform Module (TPM) encountered a non-recoverable error in the TPM hardware, which prevents TPM services (such as data encryption) from
being used. For further help, please contact the computer manufacturer.
6 3221232481 A timeout was reached (30000 milliseconds) while waiting for the GameDVR and Broadcast User Service_15bc71 service to connect.
3 20 Installation Failure: Windows failed to install the following update with error 0x80073d02: 9WZDNCRFJ364-MICROSOFT.SKYPEAPP.
1 36871 A fatal error occurred while creating a TLS client credential. The internal error state is 10013.
2 10001 The description for Event ID '10001' in Source 'DCOM' cannot be found. The local computer may not have the necessary registry information or message DLL files to display
1 3221232495 The Network List Service service terminated with the following error:
%%21
推荐阅读
- javascript - CSS 媒体查询在 Microsoft Edge 上不起作用
- r - 从列表中的行匹配的数据框中删除行
- javascript - Chrome 调试器 - 显示重复路径的“无域”部分(在 Webpack 之后)
- c# - 如何在 Xamarin 表单中创建动态单选按钮组?
- php - 使用 DOMDocument 以缩小形式保存 XML 文件
- php - 如何在 laravel 5.6 刀片中获取计数值?
- ios - Swift 4.2 - 如何在枚举函数中使用警报?
- angularjs - 执行 CORS 时自定义标头不可用
- android - Recyclerview滚动缓慢并卡住android
- ios - 在我的应用程序中点击 UITextField 时没有出现 UIKeyboard