Deal of the Day

Home » Main » Manning Forums » 2009 » Windows Powershell in Action , Second Edition

Thread: Errors and Corrections

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 26 - Pages: 2 [ Previous | 1 2 ] - Last Post: Nov 5, 2012 1:42 PM by: Polyfinario Threads: [ Previous | Next ]
BenScott

Posts: 1
From: New Hampshire, United States
Registered: 12/28/11
Re: Errors and Corrections
Posted: Dec 28, 2011 1:09 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Section 4.4.5, "The -join operator"
Page 143

A code example is given:
$csv = -join ('"',($numbers -join '","'), '"')

And then described in the text as, "You use -join to insert the sequence "," between each element and then use string concatenation to add double quotes to either end."

I don't believe the description is completely accurate for the example. String concatenation is done with the + (plus) operator. The code instead uses the -join operator twice.

To fix this erratum, one could change the code to match the description, or vice versa. I'd say it's better to simply the code, to make it clearer what the -join operator is doing (since that's the point of this section). Thus, perhaps a clearer code example would be:

$csv = '"' + ($numbers -join '","') + '"'

If one wanted to keep the nested joins, I would suggest a description of:

"You use -join to insert the sequence "," between each element, yielding a single string; that string then becomes part of an array of strings, with double quotes at either end; finally, use the unary -join to combine the array of strings with no separator." The explanation becomes quite cumbersome this way; hence the reason I favor changing the code.

(This appears in both the print edition, (C) 2011, ISBN 978-1-935182-13-9; and the PDF edition, file name "Windows_PowerShell_i_v1_PUBLISH.pdf", downloaded 28 DEC 2011, which appears to be the same thing.)

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 1, 2012 9:12 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 39: "...mentioned in figure 2.1" should be "...figure 2.2"

Interesting choice of typography for the back-reference; I'd have thought it would be "Figure 2.x" (cap'd "F").

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 2, 2012 3:14 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 171, Figure 5.10 should be "$a[2][3] -eq "world"

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 2, 2012 3:16 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

> The dead tree version, 2nd edition:
>
> p. 171, Figure 5.10 should be "$a[2][3] -eq "world"

oops... make that $a[2][1] -eq "world", anyhow, the brackets are typo'd!

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 2, 2012 7:37 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 198: one you too many:

"You can select, sort, edit,you and present..."

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 2, 2012 9:02 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 241 variables $x and $y appear out of the blue, should they be $from and $count?

"Here's a simple example of what this looks like in a real function:

function subtract ($from, $count) { $from - $count }

In this function definition, there are two formal parameters: $from and $count."

A moment later...

"PS (1) > subtract 5 3
2

In this case, the first argument, 5, is bound to the first formal parameter, $x, and the second argument is bound to the second parameter, $y."

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 3, 2012 7:33 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 331 upper left area of Figure 9.2, should be "Loads into global scope instead of module scope" (was module ccope)

qzrrbz

Posts: 7
From: MI
Registered: 2/1/12
Re: Errors and Corrections
Posted: Feb 3, 2012 7:53 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

The dead tree version, 2nd edition:

p. 335, parallelism suggrsts adding a second "who" (the one in parens) to:
NOTE Typically, the only people who remove modules are those who are developing the module in question or those (who) are working in an application environment..."

p. 338, a dyslexic, spell-check compliant typo:
"This script is indented to implement a simple counter." I suspect it may be, but probably you intended "intended"?

MikeShepard

Posts: 13
Registered: 10/2/10
Re: Errors and Corrections
Posted: Feb 7, 2012 9:01 PM   in response to: qzrrbz in response to: qzrrbz
  Click to reply to this thread Reply

In the author's note on page 391 (in section 11.2.3), there's a reference to modifying schtasks.exe output to work better with PowerShell. It mistakenly points you to section 11.7, although the discussion is actually found in appendix B.1.1

rthrelkeld

Posts: 2
Registered: 7/7/12
Re: Errors and Corrections
Posted: Jul 7, 2012 7:57 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Second Edition pdf, section 1.2.2 second paragraph, "data timestamp" should be "date timestamp".

jo1971

Posts: 4
Registered: 8/24/10
Re: Errors and Corrections
Posted: Jul 29, 2012 4:00 AM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

On page 784, the book says:

"You start by using the ScriptControl class to build a VBScript CodeObject. Be
aware that this class is not available on all versions of Microsoft Windows."

It seems that this control is part of no Windows version at all, instead it apparently comes with some Visual Basic versions (and can be separately downloaded). See also
http://support.microsoft.com/kb/184740
http://support.microsoft.com/kb/184739/EN-US

Joachim

Polyfinario

Posts: 1
Registered: 11/5/12
Re: Errors and Corrections
Posted: Nov 5, 2012 12:33 PM   in response to: luke.bace in response to: luke.bace
  Click to reply to this thread Reply

Second, corrected printing, April 2012
Intro page 4:
"http://blogs.msdn.com/b/powershell/rss.aspx" -> "b/" missing.
3.2.1 page 80:
x is 1
x is 2
x is 3 is not true because $x=1 after the former steps, need $x=0 as a reset.
3.6.1 page 103:
PS (2) > [string] $data
1 2 3 4 5 6 7 8 9 10 -> only true if $OFS is still "".
4.4.6 page 148:
in the color string the "'" after White is not needed (can give confusion?), see also the output.
5.2 page 154:
Figure 5.3 "The binary various unary operators" -> remove "binary".
5.3.1 page 159:
"Earlier in this chapter," should be "Before this chapter (in 4.2.1),".
5.4.1 page 164:
"$t1_2 = $t3,$t4" should be "$t2_2 = $t3,$t4".
5.4.5 page 172:
In PS (3) double quotes are used, in PS (4...6) single quotes -> no need, confusion.
5.8.1 page 185:
last sentence, "abc" can't be can't be converted" -> remove one "can't be".
5.8.4 page 194:
"Now the variable contains seven elements." should be "six".
"It appears that the last four arguments have vanished." should be "three".
6.4.3 page 219:
line below PS (2), the use of "continue" makes no difference in result.
6.4.4 page 221:
Read error with C:\Windows\WindowsUpdate.log: "file in use by other process". Make first a copy of this file, then statements work with this copy.
With PS (5) there is no read error !
7.2 page 241:
"... is bound to the first formal parameter, $first,.." "$first" must be "$from".
7.2.4 page 247:
"The initialization sequence as shown in figure 7.2" musi be "7.4".
7.5 page 268:
"Definition" is only ". . ." on my system.
7.6.1 page 270:
"PS (1) function one { "x is $x y is $y}" -> double quote is missing after $y.
"Function one prints out a string displaying the value of $x." -> " and $y." should be added.
"PS (4) > one
x is 7" here the output for $y is missing.
8.1.6 page 287:
With PS (3) I get $LASTEXITCODE = 1 instead of 0 ?
With PS (7) I get indeed 0.
8.2.6 page 306:
in function allowNullExample the last ")" must be "}".
page 307:
The error text is equal to the text generated by Powershell, but is not correct. "Specify more than 2 arguments" must be "Specify 2 arguments".
page 308:
"Specify less than 2 arguments" must be "Specify 2 arguments".
page 309:
"Supply an argument that is less than 10 and.." must be
"Supply an argument that is 10 or less and..".
page 310:
"The Powershell runtime understands that this and combines..." -> remove "that".
8.3.1 page 312:
"you need to use the New-Object cmdlet to create a instance.." -> "an instance..".
page 313
"Management.Automation.RuntimeDefinedParameterDictionary" is missing a "`" at the end.

This is what I have found before chapter 9.

Message was edited by:
Polyfinario

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor