Powershell - 将字符串转换为表格或其他对象? [英] Powershell - convert string to table or other object?

查看:175
本文介绍了Powershell - 将字符串转换为表格或其他对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用PowerShell的新手,我正在尝试将exe的输出转换为object \\\\ something_useful以便能够遍历数据。如果数据是水平的,我发现代码转换,但如果它是垂直的,则没有。



输出如下:



UNC路径:无

LUN路径:blah1:blah / blah

存储系统:blah1



如果有两个连接,那么它看起来像这样:



UNC路径:无

LUN路径:blah1: blah / blah

存储系统:blah1

UNC路径:无

LUN路径:blah2:blah / blah

存储系统:blah2





我希望能得到如下内容:



UNC路径LUN路径存储系统

-------- -------- ------------ -

无blah1:blah / blah blah1

无blah2:blah / blah blah2



我尝试过:



sdcli.exe磁盘列表| Tee-object -Variable DiskList

echo $ DiskList

I'm very new to using powershell, and I'm trying to convert the output of an exe to an object\table\something_useful to be able to loop through the data. I've found code converting if the data is horizontal, but not if it is vertical.

The output looks like this:

UNC Path: None
LUN Path: blah1:blah/blah
Storage System: blah1

If there are two connected, then it looks like this:

UNC Path: None
LUN Path: blah1:blah/blah
Storage System: blah1
UNC Path: None
LUN Path: blah2:blah/blah
Storage System: blah2


I'm hoping to get something that looks like the following:

UNC Path LUN Path Storage System
-------- -------- --------------
None blah1:blah/blah blah1
None blah2:blah/blah blah2

What I have tried:

sdcli.exe disk list | Tee-object -Variable DiskList
echo $DiskList

推荐答案

DiskList


这篇关于Powershell - 将字符串转换为表格或其他对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆