- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试利用新的 ConvertFrom-String Windows Management Production Preview 5 中的命令行开关.
我有一个我试图从中解析数据的字符串的 $Sample
以及我正在使用的 $Template
。
我正在获取所需的大部分数据,但由于某种原因没有获取全部数据。
我读过一篇number of blog articles关于该主题,并且无法使用 ConvertFrom-String Buddy 进行解析但我无法让它提取我需要的所有数据。
您能否让我深入了解一下我可能做错了什么,导致捕获了大部分数据但未捕获全部数据?
预先感谢您提供的任何帮助或见解。
PowerShell 版本:
PS C:\Users\alozano\Desktop> $psversiontable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10514 6
这是正在运行的 powershell 代码:
$Sample = @"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
6,708,875 CM RESET CNTR2
ALL ITEMS PASSWORD LEVEL
"@
$TemplateThatFails = @"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM} RESET CNTR2
{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
"@
$TemplateThatPartiallyWorks= @"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1}} ZBI VERSION
"@
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
Write-Host "Using ConvertFrom-String with the TemplateThatPartiallyWorks"
$Sample | ConvertFrom-String -TemplateContent $TemplateThatPartiallyWorks| select -ExpandProperty ZebraConfig
我得到以下结果:
Using ConvertFrom-String with the TemplateThatFails
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\alozano\AppData\Local\Temp\usiqowuu.p2u.input.txt and C:\Users\alozano\AppData\Local\Temp\usiqowuu.p2u-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:231 char:16
+ ... codedHTML | ConvertFrom-String -TemplateContent $TemplateThatFails | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [ConvertFrom-String], ResultNotFoundException
+ FullyQualifiedErrorId : ResultNotFound,Microsoft.PowerShell.Commands.StringManipulation.ConvertFromStringCommand
Using ConvertFrom-String with the TemplateThatPartiallyWorks
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
ZBIVersion : 2.1
这些是位于 $TemplateThatFails
末尾的 7 行,我在 $TemplateThatPartiallyWorks
中省略了它们:
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM} RESET CNTR2
{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
系统信息:
Operating System: Windows 8.1 Enterprise 64-bit (6.3, Build 9600) (9600.winblue_r9.150322-1500)
Language: English (Regional Setting: English)
System Manufacturer: Dell Inc.
System Model: Latitude E7450
BIOS: BIOS Date: 12/29/14 05:36:41 Ver: A02.00
Processor: Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz (4 CPUs), ~2.3GHz
Memory: 8192MB RAM
Available OS Memory: 8082MB RAM
最佳答案
我的设置完全相同(i5/16Gb/Win8.1 64bit/PS 5.0.10514.6)。
这有点疯狂;只有最后一行有问题。
1 - 如果您将其完全隔离并使其成为模板和示例中的唯一行,则它可以工作。
代码:
$Sample = @"
ALL ITEMS PASSWORD LEVEL
"@
$TemplateThatFails = @"
{Zebraconfig*:{PasswordLevel:ALL ITEMS}} PASSWORD LEVEL
"@
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
输出:
PasswordLevel
-------------
ALL ITEMS
0,13 seconds elapsed
2 - 如果将其移到前一个的上方(在示例和模板中),您不会收到任何错误,但数据会混淆。
代码:
$Sample = @"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
ALL ITEMS PASSWORD LEVEL
6,708,875 CM RESET CNTR2
"@
$TemplateThatFails = @"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{PasswordLevel:ALL ITEMS} PASSWORD LEVEL
{ResetCNTR2cm:6,708,875 CM}} RESET CNTR2
"@
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
输出:
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
ZBIVersion : 2.1
NonResetCNTRin : 2,641,289 IN
ResetCNTR1in : 2,641,289 IN
ResetCNTR2in : 2,641,289 IN
NonResetCNTRcm : 6,708,875 CM
ResetCNTR1cm : 6,708,875 CM
PasswordLevel : CM RESET
ResetCNTR2cm : 6,708,875 CM
36,58 seconds elapsed
3 - 如果将其移至 ZBI VERSION
(示例 + 模板)(部分工作模板中的最后一行)上方,则一切正常。
代码:
$Sample = @"
JJK072821.12Z1220126.23630-01.S.JABI
+20.0 DARKNESS
6 IPS PRINT SPEED
+000 TEAR OFF
APPLICATOR PRINT MODE
NON-CONTINUOUS MEDIA TYPE
WEB SENSOR TYPE
DIRECT-THERMAL PRINT METHOD
812 PRINT WIDTH
1874 LABEL LENGTH
9.0IN 228MM MAXIMUM LENGTH
DISABLED SUPPLIES WARNING
MAINT. OFF EARLY WARNING
CONNECTED USB COMM.
READY EXTERNAL 5V
BIDIRECTIONAL PARALLEL COMM.
RS232 SERIAL COMM.
9600 BAUD
8 BITS DATA BITS
NONE PARITY
XON/XOFF HOST HANDSHAKE
NONE PROTOCOL
000 NETWORK ID
NORMAL MODE COMMUNICATIONS
<~> 7EH CONTROL PREFIX
<^> 5EH FORMAT PREFIX
<,> 2CH DELIMITER CHAR
ZPL II ZPL MODE
ACTIVE COMMAND OVERRIDE
NO MOTION MEDIA POWER UP
NO MOTION HEAD CLOSE
OFF BACKFEED
+080 LABEL TOP
+0000 LEFT POSITION
OFF VERIFIER PORT
MODE 1 APPLICATOR PORT
ENABLED ERROR ON PAUSE
PULSE MODE START PRINT SIG
FEED MODE RESYNCH MODE
DISABLED REPRINT MODE
048 WEB S.
079 MEDIA S.
065 RIBBON S.
100 TAKE LABEL
050 MARK S.
000 MARK MED S.
002 TRANS GAIN
040 TRANS BASE
086 TRANS BRIGHT
082 RIBBON GAIN
000 MARK GAIN
DPCSWFX. MODES ENABLED
.......M MODES DISABLED
832 8/MM FULL RESOLUTION
V53.17.21Z <- FIRMWARE
1.3 XML SCHEMA
V45 ---------- 19 HARDWARE ID
CUSTOMIZED CONFIGURATION
10840k...........R: RAM
2048k............E: ONBOARD FLASH
NONE FORMAT CONVERT
*** APPLICATOR P34 INTERFACE
TWINAX/COAX ID
FW VERSION IDLE DISPLAY
11/05/15 RTC DATE
11:22 RTC TIME
DISABLED ZBI
ALL ITEMS PASSWORD LEVEL
2.1 ZBI VERSION
2,641,289 IN NONRESET CNTR
2,641,289 IN RESET CNTR1
2,641,289 IN RESET CNTR2
6,708,875 CM NONRESET CNTR
6,708,875 CM RESET CNTR1
6,708,875 CM RESET CNTR2
"@
$TemplateThatFails = @"
{Zebraconfig*:{Serial:JJK072821.12Z1220126.23630-01.S.JABI}
{Darkness:+20.0} DARKNESS
{PrintSpeed:6 IPS} PRINT SPEED
{TearOff:+000} TEAR OFF
{Applicator:APPLICATOR} PRINT MODE
{MediaType:NON-CONTINUOUS} MEDIA TYPE
{SensorType:WEB} SENSOR TYPE
{PrintMethod:DIRECT-THERMAL} PRINT METHOD
{PrintWidth:812} PRINT WIDTH
{LabelLength:1874} LABEL LENGTH
{MaximumLength:9.0IN 228MM} MAXIMUM LENGTH
{SuppliesWarning:DISABLED} SUPPLIES WARNING
{EarlyWarning:MAINT. OFF} EARLY WARNING
{USBComm:CONNECTED} USB COMM.
{External5v:READY} EXTERNAL 5V
{ParallelComm:BIDIRECTIONAL} PARALLEL COMM.
{SerialComm:RS232} SERIAL COMM.
{Baud:9600} BAUD
{DataBits:8 BITS} DATA BITS
{Parity:NONE} PARITY
{HostHandshake:XON/XOFF} HOST HANDSHAKE
{Protocol:NONE} PROTOCOL
{NetworkID:000} NETWORK ID
{Communications:NORMAL MODE} COMMUNICATIONS
{ControlPrefix:<~> 7EH} CONTROL PREFIX
{FormatPrefix:<^> 5EH} FORMAT PREFIX
{Delimiter:<,> 2CH} DELIMITER CHAR
{ZPLMode:ZPL II} ZPL MODE
{CommandOverride:ACTIVE} COMMAND OVERRIDE
{MediaPowerUp:NO MOTION} MEDIA POWER UP
{HeadClose:NO MOTION} HEAD CLOSE
{Backfeed:OFF} BACKFEED
{LabelTop:+080} LABEL TOP
{LeftPosition:+0000} LEFT POSITION
{VerifierPort:OFF} VERIFIER PORT
{ApplicatorPort:MODE 1} APPLICATOR PORT
{ErrorOnPause:ENABLED} ERROR ON PAUSE
{StartPrintSig:PULSE MODE} START PRINT SIG
{ResynchMode:FEED MODE} RESYNCH MODE
{ReprintMode:DISABLED} REPRINT MODE
{WebSensor:048} WEB S.
{MediaSensor:079} MEDIA S.
{RibbonSensor:065} RIBBON S.
{TakeLabel:100} TAKE LABEL
{MarkSensor:050} MARK S.
{MarkMedSensor:000} MARK MED S.
{TrainsGain:002} TRANS GAIN
{TransBase:040} TRANS BASE
{TransBright:086} TRANS BRIGHT
{RibbonGain:082} RIBBON GAIN
{MarkGain:000} MARK GAIN
{ModesEnable:DPCSWFX.} MODES ENABLED
{ModesDisabled:.......M} MODES DISABLED
{Resolution:832 8/MM FULL} RESOLUTION
{Firmware:V53.17.21Z <-} FIRMWARE
{XMLSchema:1.3} XML SCHEMA
{HardwareID:V45 ---------- 19} HARDWARE ID
{Configuration:CUSTOMIZED} CONFIGURATION
{RAM:10840k...........R:} RAM
{OnboardFlash:2048k............E:} ONBOARD FLASH
{FormatConvert:NONE} FORMAT CONVERT
{P34Interface:*** APPLICATOR} P34 INTERFACE
TWINAX/COAX ID
{IdleDisplay:FW VERSION} IDLE DISPLAY
{RTCDate:11/05/15} RTC DATE
{RTCTime:11:22} RTC TIME
{ZBI:DISABLED} ZBI
{PasswordLevel:ALL ITEMS} PASSWORD LEVEL
{ZBIVersion:2.1} ZBI VERSION
{NonResetCNTRin:2,641,289 IN} NONRESET CNTR
{ResetCNTR1in:2,641,289 IN} RESET CNTR1
{ResetCNTR2in:2,641,289 IN} RESET CNTR2
{NonResetCNTRcm:6,708,875 CM} NONRESET CNTR
{ResetCNTR1cm:6,708,875 CM} RESET CNTR1
{ResetCNTR2cm:6,708,875 CM}} RESET CNTR2
"@
Write-Host "Using ConvertFrom-String with the TemplateThatFails"
$startTime = Get-Date
$Sample | ConvertFrom-String -TemplateContent $TemplateThatFails | select -ExpandProperty ZebraConfig
$endTime = Get-Date
$elapsed = "{0:N2}" -f (New-TimeSpan $startTime $endTime).TotalSeconds
"$elapsed seconds elapsed"
输出:
Serial : JJK072821.12Z1220126.23630-01.S.JABI
Darkness : +20.0
PrintSpeed : 6 IPS
TearOff : +000
Applicator : APPLICATOR
MediaType : NON-CONTINUOUS
SensorType : WEB
PrintMethod : DIRECT-THERMAL
PrintWidth : 812
LabelLength : 1874
MaximumLength : 9.0IN 228MM
SuppliesWarning : DISABLED
EarlyWarning : MAINT. OFF
USBComm : CONNECTED
External5v : READY
ParallelComm : BIDIRECTIONAL
SerialComm : RS232
Baud : 9600
DataBits : 8 BITS
Parity : NONE
HostHandshake : XON/XOFF
Protocol : NONE
NetworkID : 000
Communications : NORMAL MODE
ControlPrefix : <~> 7EH
FormatPrefix : <^> 5EH
Delimiter : <,> 2CH
ZPLMode : ZPL II
CommandOverride : ACTIVE
MediaPowerUp : NO MOTION
HeadClose : NO MOTION
Backfeed : OFF
LabelTop : +080
LeftPosition : +0000
VerifierPort : OFF
ApplicatorPort : MODE 1
ErrorOnPause : ENABLED
StartPrintSig : PULSE MODE
ResynchMode : FEED MODE
ReprintMode : DISABLED
WebSensor : 048
MediaSensor : 079
RibbonSensor : 065
TakeLabel : 100
MarkSensor : 050
MarkMedSensor : 000
TrainsGain : 002
TransBase : 040
TransBright : 086
RibbonGain : 082
MarkGain : 000
ModesEnable : DPCSWFX.
ModesDisabled : .......M
Resolution : 832 8/MM FULL
Firmware : V53.17.21Z <-
XMLSchema : 1.3
HardwareID : V45 ---------- 19
Configuration : CUSTOMIZED
RAM : 10840k...........R:
OnboardFlash : 2048k............E:
FormatConvert : NONE
P34Interface : *** APPLICATOR
IdleDisplay : FW VERSION
RTCDate : 11/05/15
RTCTime : 11:22
ZBI : DISABLED
PasswordLevel : ALL ITEMS
ZBIVersion : 2.1
NonResetCNTRin : 2,641,289 IN
ResetCNTR1in : 2,641,289 IN
ResetCNTR2in : 2,641,289 IN
NonResetCNTRcm : 6,708,875 CM
ResetCNTR1cm : 6,708,875 CM
ResetCNTR2cm : 6,708,875 CM
36,32 seconds elapsed
我真的不明白发生了什么,但我已经设法抑制了错误,所以我希望这能为您指明正确的方向。
PS:为什么运行这么长时间?!
关于parsing - 使用模板的 ConvertFrom-String 未按预期解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33577350/
下面的test2和test3结果是不同的。 我对此感到困惑,因为它看起来像相同的逻辑,并且与linux bash ||逻辑不同。 $data = @( [PSCustomObject]@{St
在转换大小超过2MB的JSON字符串时,使用PowerShell v3时出现问题。 PowerShell使用的JSON序列化程序的默认限制设置为2MB,这说明了错误。 但是,当我在较小的集合上使用Co
我只是尝试使the scripting guy's example适应从文本文件读取数据并使用ConvertFrom-StringData解析哈希表: $PSVersionTable.PSVersio
我正在获取服务器的固件信息,并将其存储在变量$t中,但它以字符串的形式出现。我已经(几乎)成功地将其结构化为一个对象,以便将其导出为CSV,但是我需要一些帮助。 目前,我的主要问题是,似乎使用Conv
我正在加载一个包含一些Json的文本文件来编辑属性。但是,修改内容并将其写入文件后,Json变得无效。 我使用以下PowerShell修改文件: $manifest = Get-Content $Pa
尝试发送api请求并遍历响应,但是似乎我的响应没有反序列化到对象。 这是我在invoke-Webrequest之后得到的响应: {"isSuccess": true, "value": null, "
使用学生文本名称 Infinity 执行以下代码将返回无穷大符号而不是实际文本。任何人都可以解释为什么会这样以及可以做些什么来纠正。 $person="Infinity,One" $personspl
我的Powershell脚本中有此代码,在特殊字符部分上效果不佳。 $request = 'http://151.80.109.18:8082/vrageremote/v1/session/play
我在使用 Convertfrom-String cmdlet 时遇到问题 $value = 'something:009' $value | ConvertFrom-String -Delimiter
我有一个看起来像这样的json文件(test.json): { "root": { "key":"value" } } 我正在使用类似这样的东西将其加载到pow
This question already has an answer here: Not all properties displayed (1个答案) 12个月前关闭。 以下声明 '[{"A":1
我正在尝试解析以下 JSON: StatusCode : 0 StatusDescription : Content : {123, 10, 32, 32...} R
使用Powershell命中Web服务,并使用ConvertFrom-Json将响应转换为对象。但是,该对象是使用无法从Powershell代码访问的属性名称创建的。 如何访问属性的属性值?我什至不应
考虑以下 json 负载(只是“az 组列表”中的示例片段): [ { "id": "/subscriptions/1f512sf9-112c-4a7a-a580-665afe
为什么以下两个片段会产生不同的输出? Get-Content -Raw "test.json" | ConvertFrom-Json | %{ Write-Output "MessageTyp
我正在编写一个需要解析JSON的脚本,并且在某些文件中出现错误。错误的原因是无效的JSON,这很好,但是我希望能够检测到该错误并在脚本中处理它。好像ConvertFrom-Json不支持-ErrorA
我正在PowerShell中处理JSON文件,似乎ConvertFrom-Json仅在某些(很少)情况下更改其输入的大小写。 例如,当我这样做时: $JsonStringSrc = '{"x":2.2
我对 PowerShell 还很陌生,并且有以下代码: $jsonResponse = @" { "departments":[{"id":81,"department":"Sales"},{"id"
看起来我期望的工作方式并没有实现。我想要返回多个对象,但它似乎只返回一个。我无法做到这一点。 一个非常简单的 JSON 文件: { "$schema": "https://schema.manag
似乎我忽略了一些简单的事情,但我继续在几种不同的解析文本文件的方法上出错。 (在下面的代码中,我使用文本变量而不是文件。)我错过了什么? 要解析的文本(模拟 TXT 数据文件)是: $testText
我是一名优秀的程序员,十分优秀!