首页 > 解决方案 > Powershell中的Truncat日志消息

问题描述

我尝试使用 Powershell 截断 wifi 日志的第一行,但我不知道它为什么不起作用。谁能建议以下代码有什么问题?

(Get-WinEvent -Logname Microsoft-Windows-WLAN-AutoConfig/Operational | select -first 1).Message.split('`n')[0]

标签: powershellevents

解决方案


尝试:

(Get-WinEvent -Logname Microsoft-Windows-WLAN-AutoConfig/Operational | select -first 1).Message.split("`n")[0]

单引号字符串被视为文字,我认为您是在拆分字母 'n' :)

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-6


推荐阅读