Appendix A. PowerShell reference
This isn’t designed to be a full PowerShell reference, as that would duplicate the help system and possibly double the length of the book. I’m including the information that I tend to look up and forget where it can be found, some useful definitions, and a few pieces that aren’t in the documentation.
The help files supplied with PowerShell contain information on the cmdlets as well as the about files. These are files that contain help information about PowerShell. The topics covered include:
- Keywords such as if, for, and do
- Advanced functions
- Remoting
- Operators
To view the available about files, access them as follows:
The individual files can then be accessed using Get-Help.
We’ve seen, over the course of 15 chapters, how to manipulate various types of .NET objects with PowerShell. This section covers how to create our own objects. Add-Member was available in PowerShell v1. Using it, we can create an object and add properties to the object. We can work with that object in the same way as any other PowerShell object.
The drawback to Add-Member is that we can’t define types for the property—we can’t restrict the property to only accepting an integer or a string value. Add-Member is great if we only want to add a property or two to an existing object, but the whole approach looks messy and seems like more work than is required if we need to create a completely new object.