Computer Library windows 2008 exchange server power shell security register

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 [...]


Measure Statistical Properties of a List

1. Problem
You want to measure the numeric (minimum, maximum, sum, average) or textual (characters, words, lines) features of a list of objects.
2. Solution
Use the Measure-Object cmdlet to measure these statistical properties of a list.
To measure the numeric features of a stream of objects, pipe those objects to the Measure-Object cmdlet:
        PS >1..10 | Measure-Object–Average -Sum
        [...]


Format a Date for Output

1. Problem
You want to control the way that PowerShell displays or formats a date.
2. Solution
To control the format of a date, use one of the following options:
The Get-Date cmdlet’s –Format parameter:
PS >Get-Date -Date “05/09/1998 1:23 PM” -Format “dd-MM-yyyy @ hh:mm:ss”
09-05-1998 @ 01:23:00
PowerShell’s string formatting (–f) operator:
PS >$date = [DateTime] “05/09/1998 1:23 PM”
PS >”{0:dd-MM-yyyy @ hh:mm:ss}” [...]


Adjust Script Flow Using Conditional Statements

1. Problem
You want to control the conditions under which PowerShell executes commands or portions of your script.
2. Solution
Use PowerShell’s if, elseif, and else conditional statements to control the flow of execution in your script.
For example:
Code View: Scroll / Show All
        $temperature = 90
       
        if($temperature -le 0)
        {
           “Balmy Canadian Summer”
        }
        elseif($temperature -le [...]


Get Help on a Command

1. Problem
You want to learn about how a specific command works and how to use it.
2. Solution
The command that provides help and usage information about a command is called Get-Help. It supports several different views of the help information, depending on your needs.
To get the summary of help information for a specific command, provide the [...]