powershell - 如何使用 Powershell 从字段的多行数据中获取 .log 文件中的单行数据
问题描述
我正在从下面的查询生成日志文件。对于“描述”字段,我有多行数据并试图在单行中获取它。
示例“描述”:“测试示例应用程序
with different entries
and functionalities."
获取团队 | foreach {</p>
选择 $DisplayName =$。DisplayName, $Description = @{'Name' = 'Description' ; 'Expression' = { $ .Description.Split([System.Environment]::NewLine) -join '' } }</p>
$outtemp= $DistplayName+"^^"+$描述
$outtemp |Out-File -encoding UTF8 "D:\Sample.log" -Append }
**在日志文件中得到以下输出**
Team1^^System.Collections.Hashtable
Team2^^System.Collections.Hashtable
在 Sample.log 文件中,获取“System.Collections.Hashtable”而不是 Description 值。
期望 sample.log 文件中的以下输出:
Team1^^使用不同的条目和功能测试示例应用程序
你能帮我解决这个问题吗?
解决方案
这就是你所追求的吗?(像浏览器一样规范化字符串):
"Testing sample application
with different entries
and functionalities." -replace '\s+', ' '
结果:
Testing sample application with different entries and functionalities.
推荐阅读
- reactjs - 单击新列后如何将排序列状态设置为“asc”并更改排序状态“asc”:在React中单击选定列时更改排序状态“desc”
- php - 外部 api 翻译:模型与调用端点,laravel
- python - TypeError:graph_def 必须是 GraphDef 原型
- c - D-bus:无法创建属性:sd_bus_add_object_vtable 失败
- java - 在计算 1+2+3+4...+n 时需要帮助?
- javascript - 在上传之前调整图像大小,使用 VueJS
- firebase - 使用 Circleci 将 Gatsby 部署到 Firebase
- c# - 将gridview与List绑定,然后上下移动项目?
- c# - HttpClient 的单个实例与具有 ClientCredentias 的多个实例?
- html - UIKit - 如何对表格进行排序?