简体   繁体   English

Powershell 4.0 - plink和类似数据的数据

[英]Powershell 4.0 - plink and table-like data

I am running PS 4.0 and the following command in interaction with a Veritas Netbackup master server on a Unix host via plink: 我正在通过plink与Unix主机上的Veritas Netbackup主服务器交互运行PS 4.0和以下命令:

PS C:\batch> $testtest = c:\batch\plink blah@blersniggity -pw "blurble" "/usr/openv/netbackup/bin/admincmd/nbpemreq -due -date 01/17/2014" | Format-Table -property Status

As you can see, I attempted a "Format-Table" call at the end of this. 如您所见,我在此结束时尝试了“Format-Table”调用。

The resulting value of the variable ($testtest) is a string that is laid out exactly like the table in the Unix console, with Status, Job Code, Servername, Policy... all that listed in order. 变量($ testtest)的结果值是一个字符串,其布局与Unix控制台中的表格完全相同,包括Status,Job Code,Servername,Policy ...所有按顺序列出的字符串。 But, it populates the variable in Powershell as just that: a vanilla string. 但是,它将Powershell中的变量填充为:一个香草字符串。

I want to use this in conjunction with a stored procedure on a SQL box, which would be TONS easier if I could format it into a table. 我希望将它与SQL框上的存储过程结合使用,如果我可以将其格式化为表格,这将更容易。 How do I use Powershell to tabulate it exactly how it is extracted from the Unix prompt via Plink? 如何使用Powershell将其从Unix提示符中通过Plink提取的确切内容列表?

You'll need to parse it and create PS Objects to be able to use the format-* cmdlets. 您需要解析它并创建PS对象才能使用format- * cmdlet。 I do enough of it that I wrote this to help: 我做的很多,我写这个来帮助:

http://gallery.technet.microsoft.com/scriptcenter/New-PSObjectFromMatches-87d8ce87 http://gallery.technet.microsoft.com/scriptcenter/New-PSObjectFromMatches-87d8ce87

You'll need to be able to isolate the data and write a regex to capture the bits you want. 您需要能够隔离数据并编写正则表达式来捕获所需的位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM