ConvertFrom-String with template

时间:2017-08-17 17:25:24

标签: string powershell

我正在尝试使用模板和ConvertFrom-String从字符串输出中获取特定属性。它不使用模板并使用PropertyNames标记,但4.10等版本号被截断为4,而2017/04/11等日期更改为2/7/2017 12:00:00 AM,因此我试图使用如下模板:

$fwTemplate = @'
system> Type                     Status       Version      BuildID          ReleaseDate
----                     ------       -------      -------          -----------
IMM2(Primary)            Active       {[string]IMMVersion*:4.10}         {IMMBuild:TCOO32C}          {[string]IMMDate:2017/04/06}
IMM2(Backup)             Inactive     3.70         TCOO26H          2016/11/29
UEFI(Primary)            Active       {[string]UEFIVersion:2.40}         {UEFIBuild:TCE130J}          {[string]UEFIDate:2017/04/11}
UEFI(Backup)             Inactive     2.40         TCE130J          2017/04/11
DSA                      Active       10.2         DSALA8N          2016/10/28
system> 
'@

但是我收到以下错误:

ConvertFrom-String : ConvertFrom-String appears to be having trouble parsing your
data using the template you've provided. We'd love to take a look at what went
wrong, if you'd like to share the data and template used to parse it. We've saved
these files to C:\Users\user\AppData\Local\Temp\5lyfkyrm.c2v.input.txt and
C:\Users\user\AppData\Local\Temp\5lyfkyrm.c2v-0.template.txt - feel free to
attach them in a mail to psdmfb@microsoft.com. We will review all submissions,
although we can't guarantee a response.
At line:1 char:23
+ $fwObj = $fw.Output | ConvertFrom-String -TemplateContent $fwTemplate
+                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (Microsoft.Power...yFlashExtract():ProgramNotFoundException) [ConvertFrom-String], ProgramNotFoundException
    + FullyQualifiedErrorId : ProgramNotFound,Microsoft.PowerShell.Commands.StringManipulation.ConvertFromStringCommand

我在模板中做错了什么,或者ConvertFrom-String错误到足以保证将日志通过电子邮件发送给Microsoft进行审核?

0 个答案:

没有答案