O'Reilly logo

Windows PowerShell™ 3.0 Step by Step by Ed Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Why write Windows PowerShell scripts?

Perhaps the number-one reason to write a Windows PowerShell script is to address recurring needs. As an example, consider the activity of producing a directory listing. The simple Get-ChildItem cmdlet does a good job, but after you decide to sort the listing and filter out only files of a certain size, you end up with the command shown here:

Get-ChildItem c:\fso | Where-Object Length -gt 1000 | Sort-Object -Property name

Even using tab completion, the previous command requires a bit of typing. One way to shorten it would be to create a user-defined function (a technique that I’ll discuss later). For now, the easiest solution is to write a Windows PowerShell script. The DirectoryListWithArguments.ps1 script ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required