Попытка сделать 1 лайнер для выполнения нижеприведенного (ограничение системы, передающей скрипт в Powershell)
Попытка превратить журналы событий в строку CSV без перевода строки для чтения на другом языке
Пример кода:
(get-eventlog -LogName system -Newest 2 | select instanceid,index,entrytype,message | convertto-csv -NoTypeInformation).replace("`"`"","`",`"")
показывает:
"InstanceId","Index","EntryType","Message"
"2147489661","19981","Information","The system uptime is 961904 seconds."
"10000","19980","Error","The description for Event ID '10000' in Source 'DCOM' cannot be found. The local computer may not have the necessary registry information or message DLL files to display the message, or you may not have permission to access them. The following information is part of the event:'C:\Windows\System32\coredpussvr.exe -Embedding', '0', '{417976B7-917D-4F1E-8F14-C18FCCB0B3A8}'"
(get-eventlog -LogName system -Newest 2 | select instanceid,index,entrytype,message | convertto-csv -NoTypeInformation).contains("`r")
показывает False
(get-eventlog -LogName system -Newest 2 | select instanceid,index,entrytype,message | convertto-csv -NoTypeInformation).contains("`n")
показывает False
if ((get-eventlog -LogName system -Newest 2 | select instanceid,index,entrytype,message | convertto-csv -NoTypeInformation) -like "*`n*"){write-host "win"}
if ((get-eventlog -LogName system -Newest 2 | select instanceid,index,entrytype,message | convertto-csv -NoTypeInformation) -like "*`r"){write-host "win"}
не повезло ни на
Когда я смотрю на результат в CharArray
, я не вижу никаких символов между отображаемыми строками, которые он просто показывает
onds." "10000
Вот почему я попробовал первый пример вставки ,
между ""
, но, кажется, что-то заставляет его переводить на новую строку.
Когда я пытаюсь заменить ""
на ","
наПример кода 1 в тестовой строке работает нормально
Есть идеи?