Work with Numbers As Binary
1. Problem
You want to work with the individual bits of a number, or work with a number built by combining a series of flags.
2. Solution
To directly enter a hexadecimal number, use the 0x prefix:
       PS >$hexNumber = 0×1234
       PS >$hexNumber
       4660
To convert a number to its binary representation, supply a base of 2 to the [...]
Perform Complex Arithmetic
1. Problem
You want to use PowerShell to calculate more complex or advanced mathematical results.
2. Solution
PowerShell supports more advanced mathematical tasks primarily through its support for the System.Math class in the .NET Framework.
To find the absolute value of a number, use the [Math]::Abs() method:
       PS >[Math]::Abs(-10.6)
       10.6
To find the power (such as the square or the [...]
Convert a String to Upper/Lowercase
1. Problem
You want to convert a string to uppercase or lowercase.
2. Solution
Use the ToUpper() and ToLower() methods of the string to convert it to uppercase and lowercase, respectively.
To convert a string to uppercase, use the ToUpper() method:
       PS >”Hello World”.ToUpper()
       HELLO WORLD
To convert a string to lowercase, use the ToLower() method:
       PS >”Hello World”.ToLower()
       [...]
Search a String for Text or a Pattern
1. Problem
You want to determine if a string contains another string, or want to find the position of a string within another string.
2. Solution
PowerShell provides several options to help you search a string for text.
Use the –like operator to determine whether a string matches a given DOS-like wildcard:
       PS >”Hello World” -like “*llo W*”
       True
[...]
Place Special Characters in a String
1. Problem
You want to place special characters (such as tab and newline) in a string variable.
2. Solution
In an expanding string, use PowerShell’s escape sequences to include special characters such as tab and newline.
       PS >$myString = “Report for Today’n—————-”
       PS >$myString
       Report for Today
       —————-
3. Discussion
As discussed in Section 5.1, “Create a String,” PowerShell strings [...]
Create a String
1. Problem
You want to create a variable that holds text.
2. Solution
Use PowerShell string variables to give you a way to store and work with text.
To define a string that supports variable expansion and escape characters in its definition, surround it with double quotes:
       $myString = “Hello World”
To define a literal string (that does not [...]
Repeat Operations with Loops
1. Problem
You want to execute the same block of code more than once.
2. Solution
Use one of PowerShell’s looping statements (for, foreach, while, and do), or PowerShell’s Foreach-Object cmdlet to run a command or script block more than once. For a detailed description of these looping statements, see “Looping Statements” in . For example:
Code View: Scroll [...]
Use a COM Object
1. Problem
You want to create a COM object to interact with its methods and properties.
2. Solution
Use the New-Object cmdlet (with the –ComObject parameter) to create a COM object from its ProgID. You can then interact with the methods and properties of the COM object as you would any other object in PowerShell.
       $object = New-Object [...]
Control Access and Scope of Variables and Other Items
1. Problem
You want to control how you define (or interact with) the visibility of variables, aliases, functions, and drives.
2. Solution
PowerShell offers several ways to access variables.
To create a variable with a specific scope, supply that scope before the variable name:
       $SCOPE:variable = value
To access a variable at a specific scope, supply that scope before [...]
Pipelines
2.1. Introduction
One of the fundamental concepts in a shell is called the pipeline. It also forms the basis of one of the most significant advances that PowerShell brings to the table. A pipeline is a big name for a simple concept—a series of commands where the output of one becomes the input of the next. [...]

