Computer Library windows 2008 exchange server power shell security register

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


Add a Pause or Delay

1. Problem
You want to pause or delay your script or command.
2. Solution
To pause until the user presses ENTER, use the Read-Host cmdlet:
        PS >Read-Host “Press ENTER”
        Press ENTER:

To pause until the user presses a key, use the ReadKey() method on the $host object:
        PS >$host.UI.RawUI.ReadKey()

To pause a script for a given amount of [...]