Appendix B: Type Reference


Overview

As discussed throughout this book, and in some detail in Chapter 5, PowerShell supports a number of data types for variables called types. Appendix B includes all of the major types, along with their methods and properties. Note that the most generic-possible type, which is Object, is not included since you can't do much with it directly.

For each type, we'll also give you the PowerShell nickname, which is the type reference you can use to cast a variable into a specific type. For example:

 $var = 5 

Creates a variable $var with the contents 5, and allows $var to remain a generic Object. However, the following expression forces $var to be a System.Int32 or an integer:

 [int]$var = 5 

The [int] part is the "nickname" for the System.Int32 type.

Note that this isn't a comprehensive reference of every single type that PowerShell supports since that would be a huge list that would not be terribly useful as far as Windows administrative tasks go. With this in mind, we've limited this reference to those types you'll use often including:

  • Boolean (System.Boolean)

  • Datetime (System.DateTime)

  • Double (System.Double)

  • Hashtable (System.Collections.Hashtable. Covered in Chapter 5 instead of in this appendix.)

  • Int (System.Int32)

  • Regex (System.Text.RegularExpressions.Regex. Covered in Chapter 7 instead of in this appendix.)

  • String (System.String)

Official Names vs. PowerShell Names

In the bulleted list above, the name in parentheses is the official underlying .NET Framework class name for the type. The first name listed is the one you can place inside [square brackets] within PowerShell. We've included the .NET Framework name to aid you in learning more about the base type. Visit http://msdn.microsoft.com/library and search for the .NET Framework name to find the full documentation on the type.

We've also tried to filter the list of properties and methods to make it more useful and concise by focusing on the ones you'll use on a daily basis in administrative scripting For a complete list you can refer to the Microsoft .NET SDK documentation for a given type.

Keep in mind that many objects have similar or identical properties and methods. We've tried to list all of them with each object for your convenience. However, our examples may be somewhat generic to help keep things clear. For example, most types have a Clone method, so we've used the same example for Clone throughout to help you spot the similarity and understand that it's used the same no matter what type you're working with.



Windows PowerShell. TFM
Internet Forensics
ISBN: 982131445
EAN: 2147483647
Year: 2004
Pages: 289

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net