I am trying to leverage the new ConvertFrom-String commandlet in the Windows Management Production Preview 5.
I have a $Sample
of the string I am trying to parse data from and the $Template
that I am using.
I am getting most of the data that I am looking for but for some reason am not getting all of it.
I have read a number of blog articles about the topic and have trouble shot the parsing with ConvertFrom-String Buddy but am not able to get it to extract all of the data I need.
Can you please give me insight into what I might be doing wrong that is causing most of the data to be captured but not all of it?
Thank you in advance for any help or insight.
PowerShell Version:
PS C:\Users\alozano\Desktop> $psversiontable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10514 6
Here is the powershell code being run:
$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
I am getting the following results:
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 [email protected]. 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
These are the 7 lines that are at the end of $TemplateThatFails
and that I have left out of $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
System Info:
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
My setup is quite the same (i5/16Gb/Win8.1 64bit/PS 5.0.10514.6).
This is a bit crazy ; only the last line is a problem.
1 - If you isolate it completely and make it the only line in the template and in the sample, it works.
Code :
$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"
Output :
PasswordLevel
-------------
ALL ITEMS
0,13 seconds elapsed
2 - If you move it just above the previous one (in the sample and in the template), you don't get any error but the data is mixed up.
Code :
$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"
Output :
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 - If you move it above ZBI VERSION
(sample + template), which is the last line in the partially working template, everything is fine.
Code :
$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"
Output :
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
I really don't understand what's going on, but I have managed to suppress the error so I hope this will point you in the right direction.
PS : why is this so long to run ?!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With