Jump to ratings and reviews
Rate this book

Windows Powershell in Action

Rate this book
PowerShell replaces cobbled-together assemblies of third-party management tools with an elegant programming language and a powerful scripting shell for the Windows environment. In the tradition of Manning's ground breaking "In Action" series, this book comes from right from the source. Written by Bruce Payette, one of principal creators of PowerShell, Windows PowerShell in Action shows you how to build scripts and utilities to automate system tasks or create powerful system management tools to handle the day-to-day tasks that drive a Windows administrator's life. Because it's based on the .NET platform, PowerShell is also a powerful tool for developers and power users. Windows PowerShell in Action was written by Bruce Payette, one of the founding members of the Windows PowerShell team, co-designer of the PowerShell language and the principal author of the PowerShell language implementation. The book enables you to get the most out of the PowerShell environment. Using many examples, both small and large, this book illustrates the features of the language and environment and shows how to compose those features into solutions, quickly and effectively. This book is designed for anyone who wants to learn PowerShell and use it well. Rather than simply being a book of recipes to read and apply, this book gives you the deep knowledge about how PowerShell works and how to apply it.

551 pages, Paperback

First published February 5, 2007

25 people are currently reading
201 people want to read

About the author

Bruce Payette

5 books1 follower

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
81 (44%)
4 stars
63 (34%)
3 stars
33 (17%)
2 stars
6 (3%)
1 star
1 (<1%)
Displaying 1 - 13 of 13 reviews
Profile Image for Tamahome.
596 reviews199 followers
July 15, 2019
This is the Bible. One of the designers of powershell wrote it. If you want to read the powershell documentation, this is it. There's things in here that aren't even documented online. There's some little mistakes here and there. I wish it was less expensive and more widely known. Copying and pasting from the pdf isn't great. The forum that comes with the book isn't that active. Read the book and impress and provoke arguments with the people on stackoverflow. Powershell is very flexible. You can creatively bend it to your will. It comes with windows. I think CS intro classes should use it.

How nerdy is this? Some favorite bits of code (or inspired by):

$a,$b = 1,2
$a = $b = 2
$a,$b = $b,$a
(1,2,3)[-1] # get last one
${c:file1.txt},${c:file2.txt} = ${c:file2.txt},${c:file1.txt} # swap files
${c:file.txt} = ${c:file.txt} -replace 'old','new' # can 'file.txt' come from another var?
get-childitem | foreach {$sum = 0}{$sum++}{$sum}
invoke-command localhost,localhost,localhost {sleep 5;'done'} # concurrent, if I could fix access perms
(Get-Process notepad).foreach('Kill')
ps | foreach name
'hi.there' | foreach split .
(ps | sort Handles).where({$_.Handles -gt 1000}, 'Until')
[void] (echo discard me)
$(echo hi; echo there) | measure

using assembly System.Windows.Forms
using namespace System.Windows.Forms
[messagebox]::show('hello world')

$err = $( $output = ls foo3 ) 2>&1
if ( $(if (1 -eq 1) {'yes'}) -eq 'yes' ) { 'yep' }

switch(1,2,3,4,5,6) {
{$_ % 2} {"Odd $_"; continue}
4 {'FOUR'}
default {"Even $_"}
}

get-content variable:a | set-content -value 'there'

& { 'inline func' }
$function:foo = {'Bye!'}

workflow work {
foreach -parallel ($i in 1..3) {
sleep 5
"$i done"
}
}
work

# this looks cool
$a = start -NoNewWindow powershell {timeout 10; '1 done'}
$b = start -NoNewWindow powershell {timeout 10; '2 done'}
$c = start -NoNewWindow powershell {timeout 10; '3 done'}
$a,$b,$c | wait-process

netstat -n | select -Skip 4 |
ConvertFrom-String -pn Blank, Protocol,
LocalAddress, ForeignAddress, State |
Select Protocol, LocalAddress, ForeignAddress, State

notepad | echo # wait for it

1..5 | &{process{$_ * 2}}

[flags()] enum bits {one = 1; two = 2; three = 4}
[bits]7

$p = [PowerShell]::Create() # make another runspace
[void] $p.AddScript{Sleep 5; ls foo5; 'done'}
$r = $p.BeginInvoke(); # run in background
$p.EndInvoke($r) # wait
$p.streams.error # see any errors
$p.dispose()

# get and set a variable in a module scope
$m = get-module counter
& $m Get-Variable count
& $m Set-Variable count 33

start-threadjob { sleep 5; 'done' } # PS 6
Profile Image for Sebastian Gebski.
1,187 reviews1,339 followers
March 6, 2013
Best book about PowerShell. Period. It's massive, it covers everything you'd like it to cover. It's detailed, it even expresses some designers' rationale that cause one of another decision during product's crafting. I consider myself quite a capable script writer, but this book proved me wrong as I was finding something new I didn't know yet very frequently. If I had to find any flaws (yea, I'm picky) that would be:
* no info about the useful module archives (do not reinvent the wheel!)
* it's very detailed about language constructs and low level mechanisms but it lacks some nice real life scenarios that could integrate various features of PS in especially creative way

Anyway, it doesn't change the fact that this is a very good book. Recommended.
Profile Image for Daniel.
17 reviews2 followers
April 24, 2012
Excellent book, very detailed, it goes deep in how things are implemented in powershell. Very good book to people with previous programming exprience.
Profile Image for Sarfraz Ali.
6 reviews
January 2, 2020
So far so good, well written with lots of examples. However nothing beats scripting for specific tasks. Would recommend.
600 reviews11 followers
November 22, 2020
With more than 1000 pages this book is just too long. There may be everything worth knowing about PowerShell in this book, but you have a hard time to find it.
Author 2 books111 followers
June 14, 2015
PowerShell is not a simple language as you could expect.

If you like me, you would expect, that you can just start reusing your existing knowledge that you've gained during your programming career and easily transfer it to PowerShell environment. Unfortunately, it would not be possible.

This book is 1000 pages long and this should not surprise you any more. PowerShell has tons of features and tons of hard-to-understand-from-the-first-glance-and-some-times-even-after-second-one design decisions.

For instance, would you expect that function could return null, scalar value or collection based on the number of returned elements? This is actually one of the main features of PowerShell and you should clearly understand this. This usually doesn't matter unless you'll try to send such kind of object to .NET API.

Or, can you expect that collection equality means ... filtering? This is true as well and 1..10 -eq 4 will return 4, not true of false. So if you'll try to use this in the if statement that you could unexpected results.

Ok, PowerShell is weird but what about this book? The book itself is good but not perfect.

Main drawback from my perspective is a minimum number of practical examples and weird chapters ordering. There is a tons of stuff that describe one or another feature but in most cases this decription would not be very practical.

Another drawback that most book about PowerShell (and this in particular) are written for ITPros but not for devs. So you would see statements that PowerShell supports closures but you'll hardly find any internal implementation details.

As an overall conclusion, if you're going to write something more complex than trivial commands, you definitely need this book or something similar. Otherwise runtime behavior would looks like magic for you.

P.S. To understand some weirdness take a look at the folowing github repo with a set of PowerShell WAT's: https://github.com/nightroman/PowerSh...
Profile Image for Kevin.
44 reviews
May 30, 2012
One of the most enjoyable specific technology focused books I've ever read. Usually books that teach you a language or a framework are pretty dry and uninspiring, but this one was great. The examples used are good at illustrating the points without going overboard. But by far my favorite part were the little asides where the author explains difficult design decisions the PowerShell team had to make.
Profile Image for TK Keanini.
305 reviews76 followers
December 7, 2007
One of the better technical writers and that comes across. When a writer is passionate about the work, it transfers to the reader and that is true with this book.

There are a lot of resources on the web for a person who wants to learn Powershell but if you want to read a book and know why design decisions were made the way they were, this is the book for you.
Profile Image for Michal Paszkiewicz.
Author 2 books8 followers
February 24, 2016
Very good and in depth coverage, however it is a very long book and unless you actively code in PowerShell while reading it, you will not remember most of it. Payette definitely makes learning fun and I recommend this book to all developers working with ASP.NET.
Profile Image for Randall.
13 reviews2 followers
September 14, 2007
Great book about a great scripting language. I use PowerShell all the time at work. This book has the details on making it functional.
Profile Image for Glenn Burnside.
194 reviews9 followers
December 6, 2011
Strong reference book, I don't think they left anything unexamined. I think that I'm going to run through "Learn Powershell in a Month of Lunches" next to get more hands-on time with the language.
3 reviews1 follower
November 12, 2015
Really good book to understand language. Book was written by designer of language, so it explains not only how to use language, but also why some design desion was made.
Displaying 1 - 13 of 13 reviews

Can't find what you're looking for?

Get help and learn more about the design.