Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
PowerShell Troubleshooting Guide
PowerShell Troubleshooting Guide

PowerShell Troubleshooting Guide: Minimize debugging time and maximize troubleshooting efficiency by leveraging the unique features of the PowerShell language

eBook
€8.99 €19.99
Paperback
€24.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

PowerShell Troubleshooting Guide

Chapter 1. PowerShell Primer

This chapter will give you a very brief overview of the main features of the PowerShell language. By the end of the chapter, you will be familiar with the following topics:

  • Cmdlets
  • Functions
  • Scripts
  • Pipelines
  • Variables
  • Modules

Introduction

Windows PowerShell (or just PowerShell, for short) was introduced by Microsoft in late 2006 accompanied by little fanfare. In the last seven years, PowerShell has gone from being what might have seemed like a research project to what is now the mainstay of Windows automation and is included in every Windows operating system and most of the major Microsoft products including Exchange, System Center, SQL Server, SharePoint, and Azure.

PowerShell is often thought of as a command-line language, and that is an accurate (but incomplete) view. Working on the command line in PowerShell is a joy compared to MS-DOS batch files and most of the command-line tools that IT professionals are used to having at their fingertips work with no changes in the PowerShell environment. PowerShell is also a first-class scripting language where the knowledge you gain from the command line pays off big time. Unlike MS-DOS, PowerShell was designed from the beginning to be a powerful tool for scripting. Unlike VBScript, there is an interactive PowerShell console that allows you to iteratively develop solutions a bit at a time as you work your way through a sequence of objects, methods, and properties.

PowerShell includes several different elements that work together to create a very powerful and flexible ecosystem. While this chapter will give you an overview of several of these pieces, be aware that the PowerShell language is the subject of many books. For in-depth coverage of these topics, refer to PowerShell In Practice by Don Jones, Jeffery Hicks, and Richard Siddaway, Manning Publications.

Cmdlets

In PowerShell, a cmdlet (pronounced "command-let") describes a unit of functionality specific to PowerShell. In version 1.0 of PowerShell, the only way to create a cmdlet was by using managed (compiled) code, but 2.0 introduced advanced functions, which have the same capabilities as cmdlets. Built-in cmdlets exist to interact with the filesystem, services, processes, event logs, WMI, and other system objects. Some examples of cmdlets, which also show the flexibility in parameter passing, are shown as follows:

  • Get-ChildItem "c:\program files" –include *.dll –recurse: This cmdlet outputs all .dll files under c:\program files
  • Get-EventLog Application –newest 5: This cmdlet outputs the five most recent entries in the Application event log
  • Set-Content –path c:\temp\files.txt –value (dir c:\): This cmdlet writes a directory listing to a text file

Cmdlets are named with a two-part construction: verb-noun. Verbs in PowerShell describe the actions to be performed and come from a common list provided by Microsoft. These include Get, Set, Start, Stop, and other easy-to-remember terms. The Get-Verb cmdlet provides the list of approved verbs with some information on how the verbs can be grouped. The following screenshot shows the beginning of the list of verbs and their corresponding groups:

Cmdlets

PowerShell nouns specify on which kind of objects the cmdlet operates. Examples of nouns are Service, Process, File, or WMIObject Unlike the list of verbs, there is no managed list of approved nouns. The reason for this is simple. With every new version of Windows, more and more cmdlets are being delivered which cover more and more of the operating system's features. An up-to-date reference for verbs along with guidance between similar or easily confused verbs can be found at http://msdn.microsoft.com/en-us/library/ms714428.aspx.

Putting nouns and verbs together, you get full cmdlet names such as Get-Process and Start-Service. By providing a list of verbs to choose from, the PowerShell team has gone a long way toward simplifying the experience for users. Without the guidance of a list such as this, cmdlet authors would often be forced to choose between several candidates for a cmdlet name. For instance, Stop-Service is the actual cmdlet name, but names such as Kill-Service and Terminate-Service would both convey the same effect. Knowing that Stop is the approved verb not only makes the decision simple, it also makes it simple to guess how one would terminate a process (as opposed to a service). The obvious answer would be Stop-Process.

Cmdlets each have their own set of parameters that allow values to be supplied on the command line or through a pipeline. Switch parameters also allow for on/off options without needing to pass a value. There is a large set of common parameters that can be used with all cmdlets. Cmdlets that modify the state of the system also generally allow the use of the –Whatif and –Confirm risk mitigation parameters. Common parameters and risk mitigation parameters are covered in detail in Chapter 5, Proactive PowerShell.

The big three cmdlets

When learning PowerShell, it's customary to emphasize three important cmdlets that are used to get PowerShell to give information about the environment and objects that are returned by the cmdlets. The first cmdlet is Get-Command. This cmdlet is used to get a list of matching cmdlets, scripts, functions, or executables in the current path. For instance, to get a list of commands related to services, the Get-Command *service* command would be a good place to start. The list displayed might look like this:

The big three cmdlets

The thought behind listing Get-Command as the first cmdlet you would use is that it is used to discover the name of cmdlets. This is true, but in my experience you won't be using Get-Command for very long. The verb-noun naming convention combined with PowerShell's very convenient tab-completion feature will mean that as you get familiar with the language you will be able to guess cmdlet names quickly and won't be relying on Get-Command. It is useful though, and might show you commands that you didn't know existed. Another use for Get-Command is to figure out what command is executed. For instance, if you encountered the Compare $a $b command line and didn't know what the Compare command was, you could try the Get-Command command to find that Compare is an alias for Compare-Object.

Note

PowerShell provides aliases for two reasons. First, to provide aliases that are commands in other shells (such as dir or ls), which lead us to PowerShell cmdlets that perform similar functions. Secondly, to give abbreviations that are shorter and quicker to type for commonly used cmdlets (for example, ? for Where-Object and gsv for Get-Service). In the PowerShell community, a best practice is to use aliases only in the command line and never in scripts. For that reason, I will generally not be using aliases in example scripts.

A similar trick can be used to find out where an executable is found: Get-Command nslookup | Select-Object Path returns the path C:\Windows\system32\nslookup.exe.

The second and probably most important cmdlet is Get-Help. Get-Help is used to display information in PowerShell's help system. The help system contains information about individual cmdlets and also contains general information about PowerShell-related topics. The cmdlet help includes syntax information about parameters used with each cmdlet, detailed information about cmdlet functionality, and it also often contains helpful examples illustrating common ways to use the cmdlet.

Tip

Pay attention to the help files. Sometimes, the problem you are having is because you are using a cmdlet or parameter differently than the designer intended. The examples in the help system might point you in the right direction.

The following screenshot shows the beginning of the help information for the Get-Help cmdlet:

The big three cmdlets

Another source of information in the help files are topics about the PowerShell language. The names of these help topics start with about_, and range from a few paragraphs to several pages of detailed information. In a few cases, the about_ topics are more detailed than most books' coverage of them. The following screenshot shows the beginning of the about_Language_Keywords topic (the entire topic is approximately 13 pages long):

The big three cmdlets

The Get-Help cmdlet has a number of switches that control precisely what help information is displayed. The default display is somewhat brief and can be expanded by using the –Full or –Detailed switches. The –Examples switch displays the list of examples associated with the topic. The full help output can also be viewed in a pop-up window in PowerShell 3.0 or higher using the –ShowWindow switch.

Tip

PowerShell 3.0 and above do not ship with any help content. To view help in these systems you will need to use the Update-Help cmdlet in an elevated session.

The final member of the big three is Get-Member. In PowerShell, all output from commands comes in the form of objects. The Get-Member cmdlet is used to display the members (for example, properties, methods, and events) associated with a set of objects as well as the types of those objects. In general, you will pipe objects into Get-Member to see what you can do with those objects. An example involving services is shown as follows:

The big three cmdlets

Functions

Functions are similar to cmdlets and should follow the same naming conventions. Whereas cmdlets are compiled units of PowerShell functionality written in managed code like C#, functions are written using the PowerShell language. Starting with PowerShell 2.0, it has been possible to write advanced functions, which are very similar to cmdlets. It is possible to use common parameters and risk mitigation parameters with advanced functions. An example of a function is shown as follows:

function get-PowerShellVersionMessage{
param($name)
    $PowerShellVersion=$PSVersionTable.PSVersion
    return "We're using $PowerShellVersion, $name!"
}

Calling the function at the command line is straightforward, as shown in the following screenshot:

Functions

Scripts

Scripts are simply files with a .ps1 file extension, which contain PowerShell code. It is possible to parameterize a script file in the same way that you would a function using a Param() statement at the beginning of the file. If we were to store the following code in a file called Get-PowerShellVersionMessage.ps1, it would be roughly equivalent to the Get-PowerShellVersionMessage function in the previous section:

param($name)
    $PowerShellVersion=$PSVersionTable.PSVersion
    return "We're using $PowerShellVersion, $name!"

A security feature of PowerShell is that it won't run a script in the current directory without specifically referring to the directory, so calling this script would look like this:

.\get-powershellversionmessage –name Mike

The following screenshot shows the aforementioned code being stored in a file:

Scripts

And the output would be (on the computer I'm using): We're using PowerShell 4.0, Mike.

Note

Depending on your environment, you might not be able to run scripts until you change the execution policy. The execution policy dictates whether scripts are allowed to be executed, where those scripts can be located, and whether they need to be digitally signed. Typically, I use set-executionpolicy RemoteSigned to allow local scripts without requiring signatures. For more information about execution policies, refer to about_execution_policies.

It is also possible to define multiple functions in a script. However, when doing so, it is important to understand the concept of scope. When a script or function is executed, PowerShell creates a new memory area for definitions (for example, variables and functions) that are created during the execution. When the script or function exits, that memory is destroyed, thereby removing the new definitions. Executing a script with multiple functions will not export those functions into the current scope. Instead, the script executes in its own scope and defines the functions in that scope. When the script execution is finished, the newly created scope is exited, removing the function definitions. To overcome this situation, the dot-source operator was created. To dot-source a file means to run the file, without creating a new scope in which to run. If there was a script file with function definitions called myFuncs.ps1, dot-sourcing the file would use the following syntax:

. .\myFuncs.ps1

Note that there is a space after the first dot, and that since the script is in the current directory explicit use of the directory is required.

Pipelines

PowerShell expressions involving cmdlets and functions can be connected together using pipelines. Pipelines are not a new concept, and have been in DOS for a long time (and in Unix/Linux forever). The idea of a pipeline is similar to a conveyor belt in a factory. Materials on a conveyor belt move from one station to the next as workers or machinery work on the materials to connect, construct, or somehow modify the work in progress. In the same way, pipelines allow data to move from one command to the next, as the output of one command is treated as the input for the next. There is no practical limit to the number of commands that can be connected this way, but readability does keep command lines from continuing forever. It can be tempting to string more and more expressions together to create a single-line solution, but troubleshooting a pipeline evaluation can be tricky.

Tip

When working with long pipeline constructions, consider breaking the line into several expressions to make the execution clearer.

Prior to PowerShell, pipelines dealt with output and input in terms of text, passing strings from one program to the next regardless of what kind of information was being processed. PowerShell makes a major change to this paradigm by treating all input and output as objects. By doing this, PowerShell cmdlets are able to work with the properties, methods, and events that are exposed by the data rather than simply dealing with the string representation. The PowerShell community often refers to the methods used by string-based pipelines as parse-and-pray, which is named after the twin operations of string parsing based on an understanding of the text format and hoping that the format of the output doesn't ever change. An example, shown in the following screenshot, illustrates this quite well:

Pipelines

It's easy to think of the output of the MS-DOS dir command as a sequence of files and folders, but if the output is carefully studied, something different becomes clear. There is a tremendous amount of other information provided:

  • Volume information
  • Volume serial number
  • A directory-level caption
  • A list of files and folders
  • A count of files
  • The total size of those files
  • The number of directories
  • The space free on the drive

To work with this output and deal with, for instance, the file names, there's a tremendous amount of work that would need to be done to analyze the formatting of all of these elements. Also, there are several different formatting parameters that can be used with the MS-DOS dir command that would affect the output. By passing data between cmdlets as objects, all of this work is eliminated. The PowerShell Get-ChildItem cmdlet, which is similar to the MS-DOS dir command, outputs a sequence of file and directory objects if the current location is a filesystem location.

How pipelines change the game

To see how the choice of an object-oriented pipeline changes the way work is done, it is sufficient to look at the MS-DOS dir command. I am picking on the dir command because it has a simple function and everyone in IT has some level of experience with it. If you wanted to sort the output of a dir command, you would need to know what the parameters built into the command are. To do that, you'd do something like this:

How pipelines change the game

It's clear that the designer of the command had sorting in mind, because there is a /O option with five different ways to sort (ten if you include reverse). That is helpful, but files have a lot more than five properties. What if you wanted to sort by more than one property? Ignoring those questions for a moment, does the collection of sorting options for this command help you at all if you were trying to sort the output of a different command (say an ATTRIB or SET command)? You might hope that the same developer wrote the code for the second command, or that they used the same specifications, but you would be disappointed. Even the simple operation of sorting output is either not implemented or implemented differently by MS-DOS commands.

PowerShell takes an entirely different approach. If you were to look at the help for Get-ChildItem, you would find no provision for sorting at all. In fact, PowerShell cmdlets do not use parameters to supply sorting information. Instead, they use the object-oriented pipeline. MS-DOS developers needed to encode the sort parameters for the dir command inside the dir command itself is because that is the only place that the properties exist (including sorting criteria). Once the command has been executed, all that is left is text, and sorting text based on properties is a complex parse-and-pray operation (which we have already discussed). In PowerShell, however, the output of Get-ChildItem is a sequence of objects, so cmdlets downstream can still access the properties of the objects directly. Sorting in PowerShell is accomplished with the Sort-Object cmdlet, which is able to take a list of properties (among other things) on which to sort the sequence of objects that it receives as input. The following are some examples of sorting a directory listing in MS-DOS and also in PowerShell:

Sorting method

DOS command

PowerShell equivalent

Sort by filename

DIR /O:N

Get-childitem | sort-object Name

Sort by extension

DIR /O:E

Get-ChildItem | Sort-object Extension

Sort by size

DIR /O:S

Get-ChildItem | Sort-object Size

Sort by write date

DIR /O:D

Get-ChildItem | Sort-object LastWriteTime

Sort by creation date

Out of luck

Get-ChildItem | Sort-object CreationTime

Sort by name and size

Out of luck

Get-ChildItem | Sort-object Name,Size

It can be clearly seen by these examples that:

  • PowerShell examples are longer
  • PowerShell examples are easier to read (at least the sorting options)
  • PowerShell techniques are more flexible

The most important thing about learning how to sort directory entries using Sort-Object is that sorting any kind of objects is done the exact same way. For instance, if you retrieved a list of applied hotfixes on the current computer using Get-hotfix, in order to sort it by HotFixID, you would issue the Get-Hotfix | Sort-Object –Property HotFixID command:

How pipelines change the game

Another point to note about sorting objects by referring to properties is that the sorting is done according to the type of the property. For instance, sorting objects by a numeric property would order the objects by the magnitude of the property values, not by the string representation of those values. That is, a value of 10 would sort after 9, not between 1 and 2. This is just one more thing that you don't have to worry about.

What's the fuss about sorting?

You might be asking, why is sorting such a big deal? You'd be correct; sorting is not necessarily a tremendously important concept. The point is, the method that the designers of PowerShell took with the pipeline (that is, using objects rather than strings) that allows this sorting method also allows other powerful operations such as filtering, aggregating, summarizing, and narrowing.

Filtering is the operation of selecting which (entire) objects in the pipeline will continue in the pipeline. Think of filtering like a worker who is inspecting objects on the conveyor belt, picking up objects that are bad and throwing them away (in the bit bucket). In the same way, objects that do not match the filter criteria are discarded and do not continue as output. Filtering in PowerShell is done via the Where-Object cmdlet and takes two forms. The first form is somewhat complicated to look at, and requires some explaining. We will start with an example such as the following:

Get-ChildItem | Where-object {$_.Size –lt 100}

Hopefully, even without an explanation, it is clear that the output would be a list of files that have a size less than 100. This form of the Where-Object cmdlet takes a piece of code as a parameter (called a scriptblock), which is evaluated for each object in the pipeline. If the script evaluates to true when the object in the pipeline is assigned to the special variable $_, the object will continue on the pipeline. If it evaluates to false, the object is discarded.

PowerShell 3.0 made a couple of changes to the Where-Object cmdlet. First, it added an easier-to-read option for the $_ variable, called $PSItem. Using that, the previous command can be rewritten as follows:

Get-ChildItem | Where-object {$PSItem.Size –lt 100}

This is slightly more readable, but Version 3.0 also added a second form that simplifies it even more. If the script block is referring to a single property, a single operator, and a constant value, the simplified syntax can be used, shown as follows:

Where-Object Property Operator Value

Note that there are no braces indicating a scriptblock, and no $_ or $PSItem. The simplified syntax for our sample filter command is this:

Get-ChildItem | Where-Object Size –lt 100

Variables

PowerShell variables, similar to variables in other programming languages, are names for data stored in memory. PowerShell variable references begin with a dollar sign and are created by assigning a value with the assignment operator (the equals sign). Unlike many programming languages, you do not need to define variables before using them or even specify what type of information the variable is going to point to. For instance, the following statements are all valid:

$var = 5
$anothervar = "Hello"
$files = dir c:\

Note that while the first two assignments were simple (integer and string constants), the third involved executing a pipeline (with a single statement) and storing the results of that pipeline in a variable. The command in the third line returns a collection of more than one kind of object (it has files and folders). Note that there is no special notation required to store a collection of objects.

Several common parameters in PowerShell take the name of a variable in order to store results of some kind in that variable. The –ErrorVariable, –WarningVariable, –OutVariable parameters, and (new in Version 4.0) –PipelineVariable parameter all follow this pattern. Also, all of the *–Variable cmdlets have a –Name parameter. These parameters are expecting the name of the variable rather than the contents of the variable. The name of the variable does not include the dollar sign. In the following screenshot, you can see that the –outvariable parameter was passed the file value, which caused a copy of the output to be stored in the variable called file:

Variables

In short, referencing the content of the variable involves the dollar sign, but referencing the variable name does not.

Modules

In Version 1.0 of PowerShell, the only ways to group lists of functions were to either put script files for each function in a directory or to include several functions in a script file and use dot-sourcing to load the functions. Neither solution provided much in the way of functionality, though. Version 2.0 introduced the concept of modules. A PowerShell module usually consists of a folder residing in one of the directories listed in the PSModulePath environment variable and contains one of the following:

  • A module file (.psm1) with the same name as the folder
  • A module manifest (.psd1) with the same name as the folder
  • A compiled assembly (.dll) with the same name as the folder

One tremendous advantage that modules have over scripts is that while every function in a script is visible when the script is run, visibility of functions (as well as variables and aliases) defined within a module can be controlled by using the Export-ModuleMember cmdlet.

The following module file, named TroubleShooting.psm1, re-implements the Get-PowerShellMessage function from earlier in the chapter using a helper function (Get-Message). Since only Get-PowerShellVersionMessage was exported, the helper function is not available after the module is imported but it is available to be called by the exported function.

function Get-Message{
param($ver,$name)
  return "We're using $ver, $name!"
}

function Get-PowerShellVersionMessage{
param($name)
  $version=$PSVersionTable.PSVersion
  $message=Get-Message $version $name
  return $message
}

Export-ModuleMember Get-PowerShellVersionMessage

Importing a module is accomplished by using the Import-Module cmdlet. Version 3.0 of PowerShell introduced the concept of automatic importing. With this feature enabled, if you refer to a cmdlet or function that does not exist, the shell looks in all of the modules that exist on the system for a matching name. If it finds one, it imports the module automatically. This even works with tab-completion. If you hit the Tab key, PowerShell will look for a cmdlet or function in memory that matches, but If it doesn't find one it will attempt to load the first module that has a function whose name matches the string you're trying to complete. Listing the cmdlets that have been loaded by a particular module is as simple as the Get-Command –Module module name.

Further reading

For more information, check out the following references:

Summary

In this chapter, we have seen the main building blocks of PowerShell as a language. We have demonstrated how similar functionality can be implemented using a function, a script, and a module. An emphasis was placed on how PowerShell's use of an object-oriented pipeline gives tremendous advantages in terms of flexibility without re-implementing common features such as sorting and filtering in each function.

PowerShell provides an innovative programming and scripting experience. The next chapter will highlight various ways that the PowerShell language functions differently from other programming languages.

Left arrow icon Right arrow icon

Description

The techniques in this book apply to beginners who have just started to learn PowerShell, as well as advanced scripters who have a good grasp of the language.

What you will learn

  • Utilize PowerShell output cmdlets to provide the troubleshooting information you need
  • Use pipeline input in your functions to reduce parameter passing issues
  • Use Write cmdlets to expose the right kind of information in the right places
  • Control the environment to eliminate surprises when executing scripts
  • Create powerful scripts and functions that communicate expectations
  • Write unit tests for your PowerShell functions and scripts to ensure that they can be executed correctly

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 28, 2014
Length: 206 pages
Edition : 1st
Language : English
ISBN-13 : 9781782173588
Vendor :
Microsoft
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Nov 28, 2014
Length: 206 pages
Edition : 1st
Language : English
ISBN-13 : 9781782173588
Vendor :
Microsoft
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
PowerShell Troubleshooting Guide
€24.99
Mastering Windows PowerShell Scripting
€41.99
Active Directory with PowerShell
€36.99
Total 103.97 Stars icon
Banner background image

Table of Contents

9 Chapters
1. PowerShell Primer Chevron down icon Chevron up icon
2. PowerShell Peculiarities Chevron down icon Chevron up icon
3. PowerShell Practices Chevron down icon Chevron up icon
4. PowerShell Professionalism Chevron down icon Chevron up icon
5. Proactive PowerShell Chevron down icon Chevron up icon
6. Preparing the Scripting Environment Chevron down icon Chevron up icon
7. Reactive Practices – Traditional Debugging Chevron down icon Chevron up icon
8. PowerShell Code Smells Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(3 Ratings)
5 star 66.7%
4 star 33.3%
3 star 0%
2 star 0%
1 star 0%
miltongoh Feb 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
After reading this book for awhile, I decided to post my review according to the word “NICE”. Why this? Well, let’s see.N – NeatThe structure of this book is being planned and categorized in a way that I personally feel is neat. Although this book is primarily for readers who are not a beginner in PowerShell Technologies, however the book just walked you through bits and pieces the basic in PowerShell so that it caters to beginners who are also fast-learners. (Of course if you required more in-depth learning of PowerShell or if you are fresh to PowerShell, there are tons of books and learning resources out there. Do not worry! Earmark this book for reading purposes when you are ready!)The book is being structured in a way that it walks you through different aspect of PowerShell such as there is dependency. For example, you need to know Cmdlets before you goes into Functions. You will need to know Functions before going to Scripts. Then go to the next level of meddling with Pipelines and Modules. So all in all, this is a progressive learning over and over again from chapter to chapter.I – Intuitive and/or InstructionalAdding on to the “Neat” that I have elaborate above, I feel that the content and knowledge that I have received after reading this book is as if I am doing Self-Learning which reminds of me of all the Microsoft Official Curriculum that I have read through while preparing for my Active Directory exam for Window Server 2008. Lots of screenshots have been placed in the book to provide better illustration of the coding that the author was trying to demonstrate. On top of that, do not forget that as a reader, you have access to the ZIP Archive which contains the PowerShell Script and Module used for the various chapter. So it simply save you time to type the command out instead. Although I really encourage PowerShell lovers to type out the command rather than copying because, while you are typing, you can to interface with the various Cmdlets and you may hit into errors when you are selecting the wrong Cmdlets to perform the right tasks.Reviewing the error messages will definitely help in getting yourself prepared in troubleshooting more complex PowerShell scripts in future.C – CorrectWell, what do I mean by Correct? Do I meant that the content is Correct or the way the content is structured is Correct?No, what I actually meant is. The Author have used the Correct way to target at PowerShell lovers. In everything that we do, there may be more than one way to get to the endpoint but usually there is only one way to nail things down and make sure things are done in the Correct manner.Why is being Correct important? Take for example, if one adopts a different way of writing PowerShell script, then when the scripts are being shared with other Scripters. Then it will take others a lot of time in order to put themselves in the shoes of the original scripter. Sometime it will be worst where one will take some time to refined the scripts to their own style. What could be worst is that, if the timeline is short and there is already a shortage of resources that are available to perform a set of tasks then you wouldn’t want to expense out a resource time to reinvent the whole wheel.So let’s all adopt to a single lingo and automate the world.E – EducationI know all books are for learning, but there are definitely books that I have personally read and felt that I have learned nothing much. I would highly recommend this book to all levels of PowerShell lovers so that for beginners will have a taste of PowerShell and for advance players out there, you will get to perfect your skills.
Amazon Verified review Amazon
muhammed Shafeeque Feb 11, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This Book has to offer so much more than just troubleshooting. Author starts with a PowerShell primer and focuses on the 3 cmdlets (Get-Help, Get-Command & Get-Member ) which often many people overlook.I liked the approach from the Author on Troubleshooting process first know the best practices and follow those once you do it the troubleshooting process comes in.That's why he explains the peculiarities in PowerShell in second chapter and then the adopted PowerShell practices in the third chapter ( Filter left, Format right ).The best chapter of the book is the chapter 4 on PowerShell professionalism as the Author covers 4 most important aspects of when you are writing Production grade Scripts:1. Naming Convention2. Modularization3. Version Control4. Unit testingUnit testing examples using Pester are really good as they give you a good peek into what Pester can do for you.Chapter 5 is all about how to use PowerShell proactively to improve our scripts.Chapter 6 talks about when you deploy PowerShell scripts targeting a version, what to check so that there are no surprises.Right now in process of reading chapter 7 , till now the book has been a good read and it brushes all the good practices I have picked by following the forums and going through the Scripts of others.This Book is for you if you have already grasped basics of PowerShell and write scripts for your environment and you want your scripts to follow all the adopted best practices as that will help you later on troubleshoot them.
Amazon Verified review Amazon
Deepak Jan 29, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This Book has to offer so much more than just troubleshooting. Author starts with a PowerShell primer and focuses on the 3 cmdlets (Get-Help, Get-Command & Get-Member ) which often many people overlook.I liked the approach from the Author on Troubleshooting process first know the best practices and follow those once you do it the troubleshooting process comes in.That's why he explains the peculiarities in PowerShell in second chapter and then the adopted PowerShell practices in the third chapter ( Filter left, Format right ).The best chapter of the book is the chapter 4 on PowerShell professionalism as the Author covers 4 most important aspects of when you are writing Production grade Scripts:1. Naming Convention2. Modularization3. Version Control4. Unit testingUnit testing examples using Pester are really good as they give you a good peek into what Pester can do for you.Chapter 5 is all about how to use PowerShell proactively to improve our scripts.Chapter 6 talks about when you deploy PowerShell scripts targeting a version, what to check so that there are no surprises.Right now in process of reading chapter 7 , till now the book has been a good read and it brushes all the good practices I have picked by following the forums and going through the Scripts of others.This Book is for you if you have already grasped basics of PowerShell and write scripts for your environment and you want your scripts to follow all the adopted best practices as that will help you later on troubleshoot them.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.