PowerShell A QUICK-START GUIDE TO POWERSHELL. by Robert Sheldon

Size: px
Start display at page:

Download "PowerShell A QUICK-START GUIDE TO POWERSHELL. by Robert Sheldon"

Transcription

1 PowerShell 101 A QUICK-START GUIDE TO POWERSHELL by Robert Sheldon

2 i Contents Foreword...1 Lesson 1: Getting What You Need to Create Basic PowerShell Commands...3 Getting Started...3 Working with Cmdlets...4 Getting Help with Cmdlets...5 Getting Help with Concepts...7 Using Aliases...8 Lesson 2: How to Create Pipelines and Manage Output...11 Formatting Statement Output...14 Controlling Statement Output...16 Sorting Statement Output...17 Lesson 3: How to Use PowerShell's Operators and Wildcards...19 Comparison Operators...20 Logical Operators...23 Arithmetic Operators...26 Lesson 4: How to Properly Use Quotes When Working with Strings...29 Working with String Values...29 Escaping Special Characters in Strings...33 Lesson 5: How to Access, Create, and Use Variables...37 Built-In Variables...37 Environment Variables...39 List-Defined Variables...39 Different Data Types...41 Referencing Variables in Strings...44 Using a Variable Alone as an Argument...45 Lesson 6: How to Work with PowerShell's Built-In Drives and Create New Drives...47 Understanding PowerShell Providers...47 Working with the Built-In Drives...48 Creating PowerShell Drives...54

3 Foreword The word scripting probably makes a lot of IT admins cringe, but it s not that scary or difficult to learn. Scripting is just a set of instructions written in terms that computers can understand. The instructions tell the computer how to do something, such as how to perform a task. Just like there are different languages people speak and understand, there are different languages computers speak and understand. Windows PowerShell is one of the newest scripting languages. It was designed from scratch rather than adapted from an existing scripting language, so it has a lot of features that IT admins will appreciate. For example, like spelling in the English language, the naming conventions in many scripting languages are inconsistent. PowerShell avoids such inconsistencies, making it much easier to learn and use. PowerShell provides far more power and flexibility than traditional Windows command shells, such as cmd.exe. To help you take advantage of that power, here are six introductory lessons that explain how to use PowerShell to perform various tasks. Whether you re new to PowerShell or just want to brush up on the basics, you ll find this series informative. Here s what the six lessons cover: Lesson 1 introduces you to the concept of cmdlets, then walks you through how to run the most basic PowerShell commands. It also covers how to use PowerShell s online Help files if you run into problems. Lesson 2 shows you how to use a pipeline that is, a series of cmdlets that pass objects from one cmdlet to the next to create PowerShell statements. With PowerShell statements, you can perform more complex tasks. This lesson also shows you how to format and sort the output from those statements. Lesson 3 introduces you to PowerShell s commonly used operators and wildcards. Most likely you re already familiar with operators (e.g., AND, OR) and wildcards (e.g., *). With PowerShell s operators and wildcards, you can create expressions to use in statements. An expression is simply a block of code that PowerShell evaluates; the result of that evaluation determines what action to take. Lesson 4 shows you how to handle strings in PowerShell cmdlets. You ll learn when you need to enclose strings in quotes and whether to use single or double quotes. You ll also learn how to flag, or escape, special characters embedded in quoted strings. Lesson 5 covers variables. Variables are virtual suitcases that you can use to store and transport data in PowerShell code. PowerShell lets you use prepacked suitcases (i.e., PowerShell built-in variables and Windows environment variables, which come with data already assigned to them) or suitcases you can pack yourself (i.e., user-defined variables). Lesson 6 discusses PowerShell providers and built-in drives. In PowerShell, providers facilitate access to data stores, such as the Windows file system and registry. Despite the important role that providers play, they are, for the most part, invisible to you within PowerShell. What are visible, however, are the PowerShell drives you use to access the providers. In this lesson, you ll learn about the available drives and how to use them. 1

4 2

5 Lesson 1: Getting What You Need to Create Basic PowerShell Commands 3 Lesson 1: Getting What You Need to Create Basic PowerShell Commands By now, most administrators are familiar with Windows PowerShell. Many have downloaded it, played with it, and perhaps used it to perform ad hoc tasks as they might do in Windows command shell (cmd. exe). But PowerShell is a lot more than a simple DOS-like command shell. It s a command-line and scripting environment that leverages the Microsoft.NET Common Language Runtime (CLR) and.net Framework. When you work in the PowerShell environment, you re working with.net objects. The folder structures you view or the services you access are actually instances of objects that represent the folders and services, unlike other command shells that simply process text. As a result, PowerShell provides far more power and flexibility than traditional command shells. To help you take advantage of this power, I ve written a series of lessons that explain how to use PowerShell to perform various tasks. Each lesson builds on previous lessons in order to demonstrate important PowerShell concepts. In this lesson, I explain how to get started using PowerShell and how to run basic PowerShell commands. I also show you how to get help within PowerShell when creating those commands and how to use aliases in your commands. Getting Started PowerShell currently doesn t ship with Windows OSs, although this will change starting with Windows Server You can find Power- Shell download links and information on the Windows PowerShell Web page ( Before you download PowerShell, install.net Framework 2.0 if you don t already have it. The PowerShell installation process is quick and straightforward. Just be sure to install the PowerShell edition specific to your OS. Microsoft provides editions for Server 2008 beta 3, Windows Vista, Windows XP SP2, and Windows Server For this lesson, I m running PowerShell on XP. After PowerShell is installed, you can use it immediately. To run PowerShell, select All Programs under the Start menu, choose Windows PowerShell 1.0, and click Windows Power- Shell. When the PowerShell window appears, the command prompt displays the current working folder (C, on my system). You re now ready to start writing and executing PowerShell commands.

6 4 Lesson 1: Getting What You Need to Create Basic PowerShell Commands Working with Cmdlets PowerShell supports its own scripting language, which is based on the.net Framework. The most basic command in that language is the cmdlet (pronounced command-let). A cmdlet is similar to a function in that it performs a specific task, such as retrieving a folder s contents or updating a registry entry. PowerShell includes more than 100 built-in cmdlets. You can create additional cmdlets, but you must create them in a.net language, such as Visual Basic.NET or C#. (The Power- Shell 101 series will discuss only the built-in cmdlets.) Each cmdlet is in the form verb-noun because Microsoft wanted to use a consistent naming scheme to make PowerShell easy to learn and expand. The verb specifies the action to be taken. The noun indicates the type of object involved. For example, the Get-ChildItem cmdlet retrieves a list of items in the current working directory or container, such as the registry. To run the cmdlet, type it at the PowerShell command prompt and press Enter. The results are displayed beneath the command prompt. That s all there is to running a basic command. There will probably be times when you don t know whether there s a cmdlet for the task you need to accomplish or when you can t remember a cmdlet s name. You can view a list of all cmdlets by using the Get-Command cmdlet. Figure 1 shows part of this list, which includes the cmdlets names and syntax, but not a description of what the cmdlet does. To get that information, you can use the Get-Help cmdlet. Figure 1: Retrieving a list of cmdlets

7 Lesson 1: Getting What You Need to Create Basic PowerShell Commands 5 Getting Help with Cmdlets PowerShell includes a set of Help files that you can access directly from the Power- Shell command window with the Get-Help cmdlet. To retrieve Help information about a specific cmdlet, you use Get-Help with its -name parameter followed by the name of the cmdlet you want to learn about. Like parameters in cmd.exe commands, parameters in PowerShell cmdlets provide information that the cmdlets need to do their job. Unlike parameters in cmd.exe commands (which might start with a hyphen, a slash, or no symbol at all), parameters in PowerShell cmdlets always begin with a hyphen, which is another example of PowerShell s consistent naming scheme. Now let s take a look at an example to demonstrate how this works. A common system administrator s task is to read text files. After looking at the list of cmdlets that Get-Command provided, you think the Get-Content cmdlet might do the trick but you aren t sure. To retrieve Help information about Get- Content, run the command Get-Help -name Get-Content As Figure 2 shows, this command returns a description of the cmdlet and syntax information. The command returns the content of an item, which in this case refers to any type of file in a system. Figure 2: Retrieving Help information about Get-Content

8 6 Lesson 1: Getting What You Need to Create Basic PowerShell Commands In the past, you might have used the For command for batch files or the File- SystemObject object in a Windows Script Host (WSH) script, but in PowerShell, you simply use the Get-Content cmdlet. You can retrieve more detailed information about the syntax by adding the -full parameter to the command Get-Help -name Get-Content -full Notice that the -full parameter doesn t take a corresponding value. This type of parameter is called a switch parameter because it switches the behavior of the cmdlet. Figure 3 shows some of the information returned by this command. (On your computer, you ll need to scroll or resize your window as necessary to view the entire contents.) The PARAMETERS section provides the information you need to include parameters in your command. Two important categories of information for each parameter are Required and Position. Figure 3: Retrieving the full version of the Help file for Get-Content

9 Lesson 1: Getting What You Need to Create Basic PowerShell Commands 7 The Required category tells you whether the parameter is mandatory or optional. When Required is set to true, you must include the parameter. When Required is set to false, the parameter is optional. The Position category tells you whether a parameter must be named or whether it can be referenced by its position. When Position is set to named, you must include the parameter s name when referencing that parameter. When Position is set to a number, you can reference the parameter by its name or you can simply provide the parameter s value in its correct position. For example, as you can see in Figure 3, the -path parameter is required for Get-Content. However, you can include that parameter value in the first position without including the parameter name, as in Get-Content c:\sample.txt If a parameter value contains spaces, you must enclose the value in quotes. In the PARAMETERS section, each parameter name is followed by information in angle brackets (< >). This information specifies the type of data that the parameter value must be. As Figure 3 shows, the -path parameter value must be a string. If a set of brackets ([ ]) follow the word string, then a string array is permitted as the parameter value. In the case of switch parameters, which don t take values, the data type will read. For example, Get-Content s -force parameter is defined with this data type. This parameter overrides restrictions that might prevent the command from succeeding. The override occurs only when you include the parameter in your command. One other feature to note about parameters is that PowerShell includes a parameter-name completion feature. You need to include only enough of the parameter name to distinguish it from other parameters. For example, the command Get-Content c:\sample.txt -force is the same as Get-Content c:\sample.txt -fo Besides providing the parameter information that you need to build commands, the Help file for Get-Content includes examples of how to use the cmdlet, helpful tips in the Notes section, and resources where you find additional information. The best part is that Help files are available for all the cmdlets there are even Help files that discuss general concepts. Getting Help with Concepts PowerShell includes a set of Help files that provide overviews of various concepts. Each file begins with about_ and ends with the name of the topic. To view an alphabetical list of the about topics, run the command Get-Help about* To view information about a specific topic, you simply include the topic s full name as a parameter value. For example, to retrieve the file about flow control, run the command Get-Help about_flow_control

10 8 Lesson 1: Getting What You Need to Create Basic PowerShell Commands Figure 4, shows part of the results you can expect. As you can see, the file provides an overview of how to implement flow control in a Power- Shell script. Figure 4: Retrieving Help information about flow control Using Aliases Some of the cmdlet names can be quite verbose, an annoying characteristic if you have to continuously retype commands. Fortunately, PowerShell supports the use of aliases for referencing cmdlets. An alias is an alternate name that s usually much shorter than the actual cmdlet name. PowerShell includes a number of built-in aliases, and you can create your own aliases. To view the aliases available to your current session, run the Get-Alias cmdlet. Current session refers to your current connection to PowerShell. When you start PowerShell, you start a new session; that session persists until you close PowerShell, which ends your connection. In addition to displaying all builtin aliases and their associated cmdlets, Get-Alias displays any aliases you created in the current session and aliases defined in profiles, which are user-defined configuration settings loaded into PowerShell whenever it starts. (Profiles will be discussed in a later lesson.)

11 Lesson 1: Getting What You Need to Create Basic PowerShell Commands 9 If you want to view the aliases available for a specific cmdlet, you must qualify the Get- Alias cmdlet. For example, to view the aliases available to the Get-ChildItem cmdlet, run the command Get-Alias Where-Object {$_.definition ` -match Get-ChildItem } This command incorporates several elements that I ll explain in detail in subsequent lessons. For now, all you need to know is that the results of the Get-Alias cmdlet are sent to a Where-Object cmdlet that filters out any results that don t match Get-ChildItem. If you want to check for aliases for a different cmdlet, replace Get-ChildItem with the cmdlet name. As you can see in Figure 5, PowerShell includes three aliases that reference Get- ChildItem: gci, ls, and dir. Figure 5: Retrieving the aliases for Get_ChildItem You can use any of these aliases in place of the cmdlet name. All four of the following commands list the contents of the C:\Windows folder: Get-ChildItem c:\windows dir c:\windows ls c:\windows gci c:\windows To create an alias within the current session, use the Set-Alias cmdlet. For instance, to create an alias named cnt that references Get-Content, run the command Set-Alias cnt Get-Content You can then use cnt wherever you would use Get-Content. The alias is available until you end your session (i.e., close PowerShell). Note that you can t include parameters when defining an alias, only the cmdlet name itself. If you want to define a reference to a cmdlet and its parameters, you should create a function. You ll learn how to create a function in a later lesson.

12 10 Lesson 1: Getting What You Need to Create Basic PowerShell Commands Moving Forward In this lesson, I introduced you to the fundamental components necessary to begin exploring and using PowerShell commands, which consist of one or more cmdlets. In the following lessons, you ll learn more about how to use these cmdlets and how to create scripts that enable you to leverage Power- Shell s full capabilities. In the meantime, begin working with cmdlets. Use Power- Shell s Help file to create commands and learn about specific concepts. Try out the different parameters and learn how to create and use aliases. In no time at all, you ll be ready to incorporate PowerShell into your daily routines.

13 Lesson 2: How to Create Pipelines and Manage Output 11 Lesson 2: How to Create Pipelines and Manage Output In the previous lesson, I introduced you to the concept of cmdlets and how to run basic PowerShell commands. I also showed you how to use aliases and how to use PowerShell s Get- cmdlets to get help when creating commands. For example, you can use the Get-ChildItem cmdlet to retrieve a list of items in a folder or the Get-Content cmdlet to retrieve the content of a text file. With cmdlets and their parameters, you can run a wide variety commands that display system information or carry out tasks. However, a cmdlet alone might not always provide the full functionality you require. For this reason, PowerShell lets you create pipelines that link cmdlets together to carry out complex operations and refine the system information you retrieve. In this lesson, you ll learn how to link cmdlets into a pipeline to create PowerShell statements. You ll also learn how to format and sort statement output. Implementing a Pipeline A PowerShell pipeline is a series of cmdlets that pass objects from one cmdlet to the next. Each cmdlet generates an object and passes it down the pipeline, where it is received by the next cmdlet. The receiving cmdlet uses that object as input and generates its own output as an object. You connect cmdlets into a pipeline by using the pipe ( ) operator. Pipelining in PowerShell is different from pipelining in other command shell environments, such as the Windows command shell. In traditional environments, a command s results are returned as a single result set, which means that the entire result set must be generated before any information is passed down the pipeline. The first result is returned at the same time as the last result. In PowerShell, however, the results are streamed through the pipeline. As soon as a command returns a result, it passes it down the pipeline, and that result is immediately available to the next command in the pipeline. Let s look at an example that will help you understand how a pipeline works. If you run the cmdlet Get-Service

14 12 Lesson 2: How to Create Pipelines and Manage Output you ll receive a list of the services installed your system, similar to the list in Figure 1. Notice that the cmdlet returns the status, name, and display name of each service. Figure 1: Retrieving a list of services Suppose you want to retrieve a list of running services only. You can pipe the output from the Get- Service cmdlet to the Where-Object cmdlet, which filters the output based on the specified criteria, as shown in the statement Get-Service Where-Object {$_.status -eq running } As you can see, you use a pipe operator to connect the two cmdlets. The Get-Service cmdlet generates an object that contains the service-related information. The object is passed down the pipeline to the Where-Object cmdlet. The Where-Object cmdlet receives the object and uses the information as input. The Where-Object cmdlet filters the information based on the Status property value. Notice that the Where-Object cmdlet includes an expression enclosed in braces ({ }). If the expression evaluates to true, the Where-Object passes that object down the pipeline and filters out any other object. In this case, the Where-Object expression states that the Status property value must be equal to (specified by the -eq operator) the string running. Status is one of the properties available to the object generated by the Get- Service cmdlet. When an object is passed down the pipeline, you can access its properties, as I ve done in the Where-Object expression. To access a property in the pipeline in this manner, you use the $_ built-in variable. This variable holds the current object within the pipeline each time the Where-Object cmdlet loops through the pipeline results. You can then reference the object s properties, as in $_.Status. The output now looks similar to that in Figure 2. (You ll learn more about the Where-Object cmdlet, object properties, and operators in later lessons.)

15 Lesson 2: How to Create Pipelines and Manage Output 13 Figure 2: Retrieving a list of running services Note that you d typically enter the statement just given on one line in the Power- Shell console window. However, column widths in the magazine force us to print this statement on more than one line. Also note in Figure 2 the >> character sequence at the beginning of some of the lines in the command. This character sequence constitutes a multiline prompt. For information about when you d want to enter a statement on multiple lines in the PowerShell console window and how to properly do so. Now suppose you want to list only the display name of each running service. You can pipe the output of the Where-Object cmdlet to the Select-Object cmdlet: Get-Service where {$_.status -eq running } select displayname In this statement, the Select-Object cmdlet receives the object from the Where-Object cmdlet. In this case, the statement uses the where alias to reference the Where-Object cmdlet and the select alias to reference the Select-Object cmdlet. In the select cmdlet, you specify the name of the property (or properties) that you want to display. For this example, I ve specified the displayname property. The statement will now output results similar to those in Figure 3. The key to using pipelines is to remember that you re always working with objects. Each cmdlet generates an object that the next cmdlet in the pipeline receives. Even the final cmdlet generates an object that outputs the statement results. As you progress through the lessons, you ll learn how to use those objects and their properties to refine your PowerShell statements.

16 14 Lesson 2: How to Create Pipelines and Manage Output Figure 3: Retrieving the display names of the running services Formatting Statement Output By default, PowerShell formats a statement s output based on the type of data in that output. For example, the following statement returns data about the PowerShell process: Get-Process powershell In this case, PowerShell displays the output from this command in a table, as shown in Figure 4. Figure 4: Displaying output in a table format

17 Lesson 2: How to Create Pipelines and Manage Output 15 If you don t want the output in this default format, you can pipe the statement output to a format cmdlet. PowerShell supports four cmdlets that format output: The Format-Table cmdlet displays data in a table (Figure 4). This is the default format for most cmdlets, so you often don t need to specify it. The Format-List cmdlet displays data in a list. The Format-Wide cmdlet displays data in a wide table that includes only one property value for each item. The Format-Custom cmdlet displays data in a custom format, based on stored configuration information in a.ps1xml format file. You can use the Update- FormatData cmdlet to update a format file. (A discussion of the Update-Format- Data cmdlet and format files is beyond the scope of these lessons. See Power- Shell s Update-FormatData Help file for more information.) To change the format of the output from the preceding statement, you can pipe it to the Format-List cmdlet: Get-Process powershell Format-List Now your results will be similar to those in Figure 5. Notice that the list format displays only a subset of the information displayed in the table format. The information displayed differs between formats. Figure 5: Displaying output in a list format

18 16 Lesson 2: How to Create Pipelines and Manage Output PowerShell determines how to format the results based on object type. In other words, the format type, layout, and properties returned are specific to the type of object. For example, the results returned by the Get-ChildItem cmdlet when retrieving file system information will be different from the results returned when retrieving information about the registry because they re two different types of objects, even though the same cmdlet is used. PowerShell uses a set of complex XML format (.ps1xml) files to determine how to display the results. Controlling Statement Output When you execute a statement, PowerShell applies the default format to the output and sends that output to the console window, unless you override this behavior by using one the four format cmdlets I just described. However, you can also control where to send that output. PowerShell provides six cmdlets for controlling output: The Out-Host cmdlet sends output to the PowerShell console. This is the default output cmdlet, so you don t need to specify it. The Out-Default cmdlet sends output to the default formatting cmdlet. In addition, Out-Default delegates the outputting process to the Out-Host cmdlet. You don t need to specify the Out-Default cmdlet. The Out-File cmdlet sends output to a specified file. The Out-Null cmdlet deletes output and doesn t send it to the PowerShell console. The Out-Printer cmdlet sends output to a printer. The Out-String cmdlet converts the pipeline object to an array of strings. You can find additional information about each cmdlet in the PowerShell Help files. To control a statement s output, add the output cmdlet at the end of your pipeline. For example, the following statement formats the PowerShell process information into a list, then sends that list to the C:\ SysInfo\ps.txt file: Get-Process powershell Format-List Out-File C:\SysInfo\ps.txt When you send output to a file, PowerShell saves the content to the file but doesn t display it in the console. You can use the Out-File cmdlet to send output to any type of file that makes sense. For example, you wouldn t want to send text to a.bmp file. Although this wouldn t throw an error, you wouldn t be able to view anything when you opened the file. The Out- File cmdlet lets you choose whether to append the output to the file or replace the existing content with the output. By default, it replaces any existing content. To append the output, you need to add the -append switch to the Out-File cmdlet: Get-Process powershell Format-List Out-File C:\SysInfo\ps.txt ` -append

19 Lesson 2: How to Create Pipelines and Manage Output 17 Sorting Statement Output In addition to formatting output, you ll often find that you ll want to sort output. To sort output, you use the Sort-Object cmdlet. This cmdlet takes the input objects from the pipeline and sorts them based on the criteria you define. As I mentioned previously, Power- Shell streams the results down the pipeline from one command to the next. However, when you sort data, the Sort-Object cmdlet waits until it has all the results (objects) and then sorts them. This effectively stops the streaming process until everything is sorted. For a small result set, this isn t a problem, but it could impact performance when retrieving large amounts of data. Still, the Sort-Object cmdlet can be a handy tool. For example, suppose you want to retrieve a list of the items in the C:\Windows folder. You can use the Get- ChildItem cmdlet in a statement such as dir c:\windows where {$_.length -gt } sort -property length -descending This statement passes the output object from the Get-ChildItem cmdlet (referenced by the dir alias) to the Where-Object cmdlet (referenced by the where alias). The Where-Object cmdlet specifies that the length must be greater than (specified by -gt) 500,000 bytes. The results are then passed down the pipeline. When the Sort- Object cmdlet (referenced by the sort alias) has all the objects, it sorts them based on the defined criteria. In this case, the Sort-Object cmdlet first specifies that the sorting should be based on the Length property. The -descending switch indicates that the results should be sorted in descending order, as shown in Figure 6. If you don t specify the -descending switch, the results are sorted in ascending order. In addition, you can specify more than one property (separated by commas) on which to base the sort order. PowerShell sorts the data first by the first property specified, then by the second, and so on. Figure 6: Sorting data based on property values

20 18 Lesson 2: How to Create Pipelines and Manage Output Moving Forward As this lesson demonstrates, the PowerShell pipeline is a powerful feature that lets you combine multiple cmdlets to perform a series of successive operations on one or more objects. You can pipe together multiple cmdlets into a statement, format the output from that statement, specify where to place the output, and even sort the outputted information. In the lessons to follow, you ll learn how to enhance your statements even further so you can take full advantage of PowerShell s pipeline capabilities.

21 Lesson 3: How to Use PowerShell's Operations and Wildcards 19 Lesson 3: How to Use PowerShell's Operations and Wildcards In PowerShell, you can connect cmdlets together to create a pipeline and use the Where-Object cmdlet to filter objects passed down that pipeline. For example, in the following statement, objects from the Get-ChildItem (referenced by the dir alias) cmdlet are piped to a Where-Object cmdlet (referenced by the where alias), which filters out all items in C:\Windows, except those larger than 500,000 bytes: dir c:\windows where {$_.length -gt } Notice that the Where-Object cmdlet includes an expression that s enclosed in braces ({ }). The expression states that the current value of the Length property must be greater than 500,000. The value of the Length property is retrieved by using $_.length. The $_ symbol references the current object in the pipeline, and.length retrieves the value of the Length property. The expression then uses the -gt (greater than) operator to compare the Length property value to the value of 500,000. As with any language, PowerShell provides a set of operators that let you create expressions you can incorporate into your statements. An expression is a block of code that PowerShell evaluates; the result of that evaluation determines what action to take. For example, in the preceding statement, PowerShell determines whether the Where-Object expression is true or false. When the expression evaluates to true that is, the current object s Length property value is greater than 500,000 that object is passed down the pipeline and displayed in the output. If the expression evaluates to false that is, the current object s Length property value isn t greater than 500,000 the object is discarded and not displayed in the output. PowerShell includes a variety of operators that you can use in your expressions. This lesson describes many of those operators and provides examples of how to use them. In addition, the sidebar How to Find Out a Cmdlet s Properties, discusses how to find property names, such as those used in the Where-Object expressions in the examples provided.

22 20 Lesson 3: How to Use PowerShell's Operations and Wildcards Comparison Operators As the name suggests, comparison operators compare values. When an expression contains a comparison operator, PowerShell compares the value to the left of the operator with the value to the right of it. You saw this idea in the preceding example, in which the Length property value is compared to 500,000. PowerShell provides many comparison operators, as Table 1, shows. Let s examine some of those operators to see how they work. Table 1: PowerShell Comparison Operators Operator Description Case-sensitive version -eq Equal to -ceq -ieq -ne Not equal to -cne -ine -gt Greater than -cgt -igt -ge Greater than or equal to -cge -ige -lt Less than -clt -ilt -le Less than or equal to -cle -ile -like -notlike -match -notmatch -contains -notcontains -replace Uses wildcards to find matching patterns Uses wildcards to find nonmatching patterns Uses regular expressions to find matching patterns Uses regular expressions to find nonmatching patterns Determines whether value on the left side of the operator contains the value on the right Determines whether value on the left side of the operator does not contain the value on the right Replaces part or all of the value on left side of the operator -clike -cnotlike -cmatch -cnotmatch -ccontains -cnotcontains -creplace Explicit case-insensitive version -ilike -inotlike -imatch -inotmatch -icontains -inotcontains -ireplace

23 Lesson 3: How to Use PowerShell's Operations and Wildcards 21 The following statement does the opposite of the preceding example; it returns items whose lengths are smaller than 500,000 bytes: dir c:\windows where {$_.length -lt } As you can see, the only difference between the two statements is the comparison operator. This statement uses the -lt (less than) operator rather than the -gt operator. Other comparison operators follow the same logic. The following statement uses the -eq (equal to) operator to compare the Responding property value to the string true in order to retrieve a list of responding processes: get-process where {$_.responding -eq true } For the Where-Object expression to evaluate to true, the Responding property value must equal true. As a result, only responding processes are returned, as Figure 1 shows. Figure 1: Retrieving a list of processes

24 22 Lesson 3: How to Use PowerShell's Operations and Wildcards By default, all comparison operators perform case-insensitive comparisons. If you want to be more precise in your code, you can add the letter i to a comparison operator (e.g., -ieq) to explicitly specify a case-insensitive comparison. However, because this is the default behavior, adding the i isn t necessary. You can make any comparison case sensitive by adding the letter c to the comparison operator (e.g., -ceq). For example, the statement True -eq true evaluates to true because it ignores case, whereas the statement True -ceq true evaluates to false because it takes case into account. I realize that these are very basic examples, but when working in a Windows environment, case often isn t a concern because filenames, process names, and other item names are case-insensitive. But as you become more familiar with PowerShell and learn how to retrieve other types of lists in which case-sensitivity is important, you ll find being able to make an operator casesensitive useful. Another useful PowerShell feature is wildcards. For example, if you don t know the exact name of an item when creating an expression to compare values, you can use wildcards in the compared value (the value after the operator). Table 2 describes the wildcards that PowerShell supports. Table 2: PowerShell Wildcards Operator Description Example True (match) False (no match) * Matches zero or more of any character? Matches any one character [char-char] [char ] Matches a range of sequential characters Matches any one character in a set of characters ab* ab, abc, about against r?d red, rid, rod bed [a-h]ug bug, dug, hug lug [cft]ool cool, fool, tool pool You implement wildcards through the use of the -like and -notlike comparison operators. (Note that -like and -notlike as well as -match, -notmatch, and -replace are sometimes referred to as patternmatching operators.) For instance, suppose you want to find all Google-related processes on a computer. You can use the -like operator to return all processes created by companies whose name includes the string google: et-process where {$_.company -like *google* }

25 Lesson 3: How to Use PowerShell's Operations and Wildcards 23 The asterisk wildcard matches zero or more characters, so you ll receive accurate results no matter whether the company name is stored in Windows as Google, Google Inc., or another variation. Figure 2 shows the results from this statement. If you were to use the -notlike operator instead of the -like operator, all non-google processes would be returned. Figure 2: Retrieving a list of Google-related processes In addition to wildcards, PowerShell supports regular expressions, which are based on the Microsoft.NET Framework regular expression classes. You implement regular expressions through the use of the -match and -notmatch operators. PowerShell s support for regular expressions is quite extensive as extensive as you would find in any.net language. For this reason, a discussion about them is beyond the scope of this lesson. For information about them, see PowerShell s about_regular_expression and about_comparison_ operators Help files. Logical Operators So far, I ve discussed how to use comparison operators in expressions. When you use one of these operators, you create a condition that s evaluated to determine whether to take a specific action. However, in some cases, you might want to create expressions that include multiple conditions. In other words, you might want to perform more than one comparison to determine whether to take that action. To perform multiple comparisons in a single expression, you must use logical operators to link conditions together. Logical operators, which are described in Table 3, specify what logic to use when evaluating multiple conditions. Let s take a look at an example to illustrate how logical operators work. The following statement uses the Get- Process cmdlet to retrieve a list of running processes: Get-Process where {($_.handles -gt 500) ` -and ($_.pm -ne 0)} Table 3: PowerShell Logical Operators Operator -and -or -not Description Both conditions must be true for expression to evaluate to true One or both conditions must be true for expression to evaluate to true Specified condition must be false for expression to evaluate to true! Specified condition must be false for expression to evaluate to true

26 24 Lesson 3: How to Use PowerShell's Operations and Wildcards There are two conditions, each of which is enclosed in parentheses. The first condition ($_.handles -gt 500) specifies that the number of handles must be greater than 500 for a given process. The second condition ($_.pm -ne 0) specifies that the paged memory size must not equal 0. The -and logical operator connects these two conditions. As a result, both conditions must evaluate to true for the entire expression (enclosed in braces) to evaluate to true. Only those processes that meet both of these conditions are returned, as Figure 3 shows. Figure 3: Using the -and operator in an expression Now let s take a look at the -or operator. The following statement is the same as the preceding example except that it uses -or instead of -and: get-process where {($_.handles -gt 500) ` -or ($_.pm -ne 0)}

27 Lesson 3: How to Use PowerShell's Operations and Wildcards 25 Figure 4: Using the -or operator in an expression In this case, at least one of the conditions must evaluate to true for a process to be included. In other words, the process must have a handle count greater than 500 or the paged memory size must not equal 0 or both. As a result, many more processes are returned, as Figure 4 shows. You can use the -not logical operator to indicate that a specified condition must not be true. For example, the following statement specifies that the handle count must be greater than 100 and the company name must not be Microsoft Corporation: get-process where {($_.handles -gt 100) ` -and -not ($_.company -eq ` Microsoft Corporation )}

28 26 Lesson 3: How to Use PowerShell's Operations and Wildcards This statement returns all non-microsoft processes, as Figure 5 shows. Figure 5: Using the -not operator in an expression Arithmetic Operators PowerShell supports the use of arithmetic operators to perform mathematical calculations. Table 4 describes the operators and provides basic examples. Table 4: PowerShell Arithmetic Operators Operator Description Example Result + Adds two values Subtracts one value from another - Converts a value to a negative number * Multiples two values 10 * 5 50 / Divides two values 10 / 5 2 % Returns the remainder from divided numbers 10 % 3 1

29 Lesson 3: How to Use PowerShell's Operations and Wildcards 27 In addition to using the operators for mathematical calculations, you can use some of the operators other ways. For example, you can use the + operator to concatenate string values: Use + to add two + + strings together. Figure 6 shows the results of concatenating these two values. Figure 6: Using arithmetic operators to concatenate strings This figure also shows the results for the statement: abc * 4 In this case, the * operator is used to multiply a string value four times. As a result, four copies of the value are returned, and those values are concatenated into one string. My arithmetic-operator examples are very basic. As you work through the lessons, you ll see more complex examples of how these operators can be used. This section is meant only to introduce you to the arithmetic operators so that you can begin to use them. To learn more about these types of operators, see the about_arithmetic_operators Help file. Moving Forward In this lesson, you learned that PowerShell supports a number of operators that let you create expressions and perform calculations. However, this lesson doesn t cover all operators. For example, Power- Shell also supports bitwise operators that perform binary operations and assignment operators that assign values to variables. I ll be covering many of these operators as we progress through the lessons. In the meantime, refer to the Power-Shell Help files to learn more about the available operators.

30 28 Lesson 3: How to Use PowerShell's Operations and Wildcards How to Find Out a Cmdlet s Properties In the Where-Object expressions I use in this lesson, I specify several cmdlet properties, such as Length and Handles. You can use the Get-Member cmdlet to retrieve the members (e.g., properties, methods) of cmdlets and other objects. Unlike the Get-Command, Get-Content, and Get- Help cmdlets described in Lesson 1, you can t use the Get-Member cmdlet in a statement such as Get-Member Get-Process To use Get-Member, you must first specify the object whose members you want to retrieve, pass that object down the pipeline, then specify Get-Member. For example, to view the members available to the Get- Process cmdlet, you d enter Get-Process Get-Member Figure A shows the members returned by this statement. Notice the AliasProperty entries under the MemberType column. In addition to regular properties, PowerShell supports alias properties and script properties. An alias property (AliasProperty) is an alternative name for a regular property. For example, the Name alias property refers to the ProcessName property. A script property (ScriptProperty) is a property whose value is the output of a script. For example, the Company property generates a script that retrieves the CompanyName property associated with a specific process object. For more information about the Get-Member cmdlet, see PowerShell s Get-Member Help file. You can find additional information about all the supported member types at technet.microsoft.com/en-us/library/ bb aspx. Figure A: Members returned by the Get-Member cmdlet

31 Lesson 4: How to Properly Use Quotes When Working with Strings 29 Lesson 4: How to Properly Use Quotes When Working with Strings Most PowerShell statements include string values. Usually, these strings are passed to cmdlets as arguments. In some cases, the strings are enclosed in single quotes. In other cases, they re enclosed in double quotes. And sometimes they re not enclosed in quotes at all. It s important to understand how to properly handle strings. The rules that govern how to do so are often referred to as quoting rules. In this lesson, you ll learn about these rules. Specifically, you ll learn when to enclose string values in quotes and whether to use single or double quotes. In addition, you ll learn how to flag, or escape, special characters. Working with String Values Whenever you enclose text in quotes, PowerShell treats that text as a string value. So, as long as the text doesn t contain any special characters (you ll learn more about these characters shortly) or reference variables (I ll discuss how to reference variables in strings in the next lesson), you can enclose the text in either single or double quotes. For example, the following statements achieve the same results: Write-Output String in quotes. Write-Output String in quotes. In these examples, the Write-Output cmdlet sends a string object down the pipeline or, in this case, directly to the PowerShell console. As you can see in Figure 1, the outputted value is the same for both statements. Figure 1: Enclosing strings in single and double quotes

32 30 Lesson 4: How to Properly Use Quotes When Working with Strings In addition to the Write-Output cmdlet, PowerShell s Out-Host and Write-Host cmdlets output information to the console. Their differences lie in the details. For example, the Write-Output cmdlet sends output down the pipeline to the next cmdlet. When Write-Output is the last cmdlet in the pipeline, the output is displayed in the console. The Out-Host cmdlet sends output directly to the console and offers an optional parameter that lets you view the output one screen at a time, which can be helpful if there is a lot of output. This is the default output cmdlet, so if you don t specify an output cmdlet, Out-Host cmdlet is used. The Write-Host cmdlet also sends output directly to the console. However, Write-Host has two optional parameters that let you change the color of the text or text background, thereby creating a customized console. For basic quoted string values that you want to output directly to the console window, all three cmdlets behave in similar ways. For example, the following four commands all display the string in the console window in the same way as in Figure 1: String in quotes. Write-Output String in quotes. Write-Host String in quotes. Out-Host ` -InputObject String in quotes. Notice that no cmdlet is specified in the first command. As a result, the Out-Host cmdlet is used. For many of the examples in this lesson, I use the Write-Output cmdlet because it outputs an object in a way similar to many other cmdlets. This lets me demonstrate different principles about quoted values. Keep in mind, however, that the Write-Output, Out- Host, and Write-Host cmdlets can behave differently in different circumstances. For more information about these cmdlets, see their Help files. If you want to include quotes within a string, you can use single quotes within double quotes or double quotes within single quotes: Write-Output String in quotes. Write-Output String in quotes. If you refer again to Figure 1, you ll see that inside quotes in both cases are carried to the output. This isn t the case when you use the same type of quotes throughout the string: Write-Output String in quotes. Write-Output String in quotes. As Figure 1 shows, the results are quite different. In both cases, the quotes are not displayed and a new line is added. This is because PowerShell interprets the one string as multiple strings and consequently adds a line break. For example, PowerShell interprets String as the first string (so it adds a line break after that string), then interprets the rest as a different string. You can use double quotes within double quotes, but you must escape the inside quotes, which I ll describe how to do later. Whenever you work with quotes, be careful not to mix up the type of quotes or forget to include one. Otherwise, you might get stuck in a loop that continues to prompt you for an entry, but nothing you enter gets you out of the loop. If you run into that situation, press Ctrl+C to return to the command prompt.

33 Lesson 4: How to Properly Use Quotes When Working with Strings 31 Another issue to take into account when defining cmdlet arguments is how Power- Shell treats numerical values. As I said earlier, PowerShell treats any values within quotes as strings, even if the value consists of all numbers: Write-Output 123 When you execute this statement, the value returned is a string object, as Figure 2 shows. Figure 2: Working with numerical values in strings You can verify the value s type by running the statement: (Write-Output 123 ).GetType() This statement uses the GetType method of the object s type, which in this case is String, or more specifically System.String, also shown in Figure 2. For more information about System.String and Get- Type, see the sidebar Getting and Using the System.String Object s Members. If you don t enclose a numerical value in quotes, PowerShell treats the value as a numerical object. For example, the following statement returns an integer object: Write-Output 123

34 32 Lesson 4: How to Properly Use Quotes When Working with Strings Again, you can verify the object s type by using the GetType method: (Write-Output 123).GetType() As you can see in Figure 2, the object s type is Int32. If a value includes both numbers and letters, PowerShell treats it as a string, whether or not it s in quotes. For example, the following statement returns a string, as verified by the second statement: Write-Output 123output (Write-Output 123output).GetType() Once again, Figure 2 shows the output of these statements. In most cases, you can omit quotes if your argument is a string with no embedded spaces. For example, the following three statements use the Set-Location cmdlet to set the working folder to the C drive: Set-Location C:\ Set-Location C:\ Set-Location C:\ Now suppose you want to change the working folder to C:\Documents and Settings: Set-Location ` C:\Documents and Settings This statement generates an error because it doesn t know what to do with the tokens (words) after the first space. As you can see in Figure 3, the parser interprets and as a parameter, and because there s no parameter by this name, the parser generates an error. Figure 3: Handling arguments improperly results in an error message You can easily fix this problem by enclosing the entire argument in quotes: Set-Location ` C:\Documents and Settings

SUNGARD SUMMIT 2007 sungardsummit.com 1. Microsoft PowerShell. Presented by: Jeff Modzel. March 22, 2007 Course ID 453. A Community of Learning

SUNGARD SUMMIT 2007 sungardsummit.com 1. Microsoft PowerShell. Presented by: Jeff Modzel. March 22, 2007 Course ID 453. A Community of Learning SUNGARD SUMMIT 2007 sungardsummit.com 1 Microsoft PowerShell Presented by: Jeff Modzel March 22, 2007 A Community of Learning Agenda Introduction to PowerShell PowerShell Power Developer Angle Long Term

More information

Windows PowerShell Essentials

Windows PowerShell Essentials Windows PowerShell Essentials Windows PowerShell Essentials Edition 1.0. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights

More information

Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p.

Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p. Introduction p. xv Acknowledgments p. xx Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p. 3 Installing.NET Framework 2.0 p.

More information

POWERSHELL (& SHAREPOINT) This ain t your momma s command line!

POWERSHELL (& SHAREPOINT) This ain t your momma s command line! POWERSHELL (& SHAREPOINT) This ain t your momma s command line! JAMYE FEW SENIOR CONSULTANT 12+ years as IT Professional ( IT PRO duck DEV ) A little IT PRO, little more DEV and a lot of ducking. Certifiable

More information

Microsoft. Jump Start. M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0

Microsoft. Jump Start. M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0 Microsoft Jump Start M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0 Rick Claus Technical Evangelist Microsoft Ed Liberman Technical Trainer Train Signal Jump Start Target Agenda Day One

More information

PowerShell for Exchange Admins

PowerShell for Exchange Admins PowerShell for Exchange Admins Get-Speaker FL Name : Kamal Abburi Title : Premier Field Engineer Expertise : Exchange Email : Kamal.Abburi@Microsoft.com Blog : mrproactive.com Note: Inspired by my fellow

More information

WolfTech Active Directory: PowerShell

WolfTech Active Directory: PowerShell WolfTech Active Directory: PowerShell March 7th, 2012 2-4pm Daniels 201 http://activedirectory.ncsu.edu What we are going to cover... Powershell Basics Listing Properties and Methods of Commandlets.Net

More information

Things I wish I d known when I started using PowerShell

Things I wish I d known when I started using PowerShell PowerShell Day 1 Things I wish I d known when I started using PowerShell John D. Cook http://www.johndcook.com First released 9 April 2009, last updated 1 February 2010 Introduction This booklet captures

More information

Powershell Management for Defender

Powershell Management for Defender Powershell Management for Defender 2012 Quest Software, Inc. ALL RIGHTS RESERVED. This guide contains proprietary information protected by copyright. The software described in this guide is furnished under

More information

Exploring PowerShell. Using Windows PowerShell

Exploring PowerShell. Using Windows PowerShell 733 Exploring PowerShell Before using PowerShell, you might want to become more familiar with its cmdlets and features. To assist administrators with exploring PowerShell, the PowerShell team decided to

More information

Forefront Management Shell PowerShell Management of Forefront Server Products

Forefront Management Shell PowerShell Management of Forefront Server Products Forefront Management Shell PowerShell Management of Forefront Server Products Published: October, 2009 Software version: Forefront Protection 2010 for Exchange Server Mitchell Hall Contents Introduction...

More information

Microsoft Windows PowerShell v2 For Administrators

Microsoft Windows PowerShell v2 For Administrators Course 50414B: Microsoft Windows PowerShell v2 For Administrators Course Details Course Outline Module 1: Introduction to PowerShell the Basics This module explains how to install and configure PowerShell.

More information

Jeffrey Snover Distinguished Engineer & Lead Architect Jason Helmick Senior Technologist, Concentrated Technology

Jeffrey Snover Distinguished Engineer & Lead Architect Jason Helmick Senior Technologist, Concentrated Technology Jeffrey Snover Distinguished Engineer & Lead Architect Jason Helmick Senior Technologist, Concentrated Technology Meet Jeffrey Snover @jsnover Distinguished Engineer & Lead Architect for Windows Server

More information

Windows PowerShell Cookbook

Windows PowerShell Cookbook Windows PowerShell Cookbook Lee Holmes O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Table of Contents Foreword Preface xvii xxi Part I. Tour A Guided Tour of Windows PowerShell

More information

Windows PowerShell Fundamentals

Windows PowerShell Fundamentals Windows PowerShell Fundamentals Steven Murawski Senior Windows Systems Engineer Microsoft MVP This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy

More information

Note: The scripts in this article should work for XenApp 6 and XenApp 5 for Windows Server 2008 and XenApp 5 for Windows Server 2003.

Note: The scripts in this article should work for XenApp 6 and XenApp 5 for Windows Server 2008 and XenApp 5 for Windows Server 2003. Recently I was asked how to use PowerShell to get a list of offline Citrix XenApp servers. Being new to PowerShell, this gave me an opportunity to use some of my new knowledge. At the time this article

More information

Specifications of Paradox for Windows

Specifications of Paradox for Windows Specifications of Paradox for Windows Appendix A 1 Specifications of Paradox for Windows A IN THIS CHAPTER Borland Database Engine (BDE) 000 Paradox Standard Table Specifications 000 Paradox 5 Table Specifications

More information

How to test and debug an ASP.NET application

How to test and debug an ASP.NET application Chapter 4 How to test and debug an ASP.NET application 113 4 How to test and debug an ASP.NET application If you ve done much programming, you know that testing and debugging are often the most difficult

More information

Using SQL Queries in Crystal Reports

Using SQL Queries in Crystal Reports PPENDIX Using SQL Queries in Crystal Reports In this appendix Review of SQL Commands PDF 924 n Introduction to SQL PDF 924 PDF 924 ppendix Using SQL Queries in Crystal Reports The SQL Commands feature

More information

ActiveRoles Management Shell for Active Directory

ActiveRoles Management Shell for Active Directory ActiveRoles Management Shell for Active Directory Version 1.5 Administrator Guide 2010 Quest Software, Inc. ALL RIGHTS RESERVED. This guide contains proprietary information protected by copyright. The

More information

Lab Answer Key for Module 1: Installing and Configuring Windows Server 2008. Table of Contents Lab 1: Configuring Windows Server 2008 1

Lab Answer Key for Module 1: Installing and Configuring Windows Server 2008. Table of Contents Lab 1: Configuring Windows Server 2008 1 Lab Answer Key for Module 1: Installing and Configuring Windows Server 2008 Table of Contents Lab 1: Configuring Windows Server 2008 1 Information in this document, including URL and other Internet Web

More information

POWERSHELL FOR NEWBIES Getting started with PowerShell 4.0. Jeffery Hicks

POWERSHELL FOR NEWBIES Getting started with PowerShell 4.0. Jeffery Hicks POWERSHELL FOR NEWBIES Getting started with PowerShell 4.0 Jeffery Hicks Abstract This ebook is intended as a quick start guide for IT Professionals who want to learn about Windows PowerShell. The ebook

More information

Troubleshoot Using Event Log Mining

Troubleshoot Using Event Log Mining Troubleshoot Using Event Log Mining Jeff Hicks 1. 8 0 0. 8 1 3. 6 4 1 5 w w w. s c r i p t l o g i c. c o m / s m b I T 2011 ScriptLogic Corporation ALL RIGHTS RESERVED. ScriptLogic, the ScriptLogic logo

More information

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2 Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................

More information

ACADEMIC TECHNOLOGY SUPPORT

ACADEMIC TECHNOLOGY SUPPORT ACADEMIC TECHNOLOGY SUPPORT Microsoft Excel: Formulas ats@etsu.edu 439-8611 www.etsu.edu/ats Table of Contents: Overview... 1 Objectives... 1 1. How to Create Formulas... 2 2. Naming Ranges... 5 3. Common

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

You Should Be Using PowerShell Aaron Kaiser Senior Technology Support Specialist Parkway School District

You Should Be Using PowerShell Aaron Kaiser Senior Technology Support Specialist Parkway School District You Should Be Using PowerShell Aaron Kaiser Senior Technology Support Specialist Parkway School District Why PowerShell? Most modern Microsoft GUI s are built upon PowerShell A number of third party applications

More information

Windows PowerShell. 3.0 Step by Step. Ed Wilson

Windows PowerShell. 3.0 Step by Step. Ed Wilson Windows PowerShell 3.0 Step by Step Ed Wilson Foreword Introduction xix xxi Chapter 1 Overview of Windows PowerShell 3.0 1 Understanding Windows PowerShell 1 Using cmdlets 3 Installing Windows PowerShell

More information

X1 Professional Client

X1 Professional Client X1 Professional Client What Will X1 Do For Me? X1 instantly locates any word in any email message, attachment, file or Outlook contact on your PC. Most search applications require you to type a search,

More information

Microsoft Excel 2010 Part 3: Advanced Excel

Microsoft Excel 2010 Part 3: Advanced Excel CALIFORNIA STATE UNIVERSITY, LOS ANGELES INFORMATION TECHNOLOGY SERVICES Microsoft Excel 2010 Part 3: Advanced Excel Winter 2015, Version 1.0 Table of Contents Introduction...2 Sorting Data...2 Sorting

More information

Exercise 1: Python Language Basics

Exercise 1: Python Language Basics Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,

More information

HOUR 3 Creating Our First ASP.NET Web Page

HOUR 3 Creating Our First ASP.NET Web Page HOUR 3 Creating Our First ASP.NET Web Page In the last two hours, we ve spent quite a bit of time talking in very highlevel terms about ASP.NET Web pages and the ASP.NET programming model. We ve looked

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

Using Process Monitor

Using Process Monitor Using Process Monitor Process Monitor Tutorial This information was adapted from the help file for the program. Process Monitor is an advanced monitoring tool for Windows that shows real time file system,

More information

Automating Microsoft

Automating Microsoft Automating Microsoft Windows Server 2008 R2 with Windows PowerShell 2.0 Matthew Hester Sarah Dutkiewicz WILEY Wiley Publishing. Inc. TABLE OF CONTENTS Introduction xvii Chapter 1 What Is PowerShell, and

More information

Hands-On UNIX Exercise:

Hands-On UNIX Exercise: Hands-On UNIX Exercise: This exercise takes you around some of the features of the shell. Even if you don't need to use them all straight away, it's very useful to be aware of them and to know how to deal

More information

Hypercosm. Studio. www.hypercosm.com

Hypercosm. Studio. www.hypercosm.com Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...

More information

Demonstration of Windows XP Privilege Escalation Exploit

Demonstration of Windows XP Privilege Escalation Exploit Demonstration of Windows XP Privilege Escalation Exploit This article is a tutorial on how to trick Windows XP into giving you system privileges. Using simple command line tools on a machine running Windows

More information

Dynamics CRM for Outlook Basics

Dynamics CRM for Outlook Basics Dynamics CRM for Outlook Basics Microsoft Dynamics CRM April, 2015 Contents Welcome to the CRM for Outlook Basics guide... 1 Meet CRM for Outlook.... 2 A new, but comfortably familiar face................................................................

More information

Visual Logic Instructions and Assignments

Visual Logic Instructions and Assignments Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.

More information

Evaluator s Guide. PC-Duo Enterprise HelpDesk v5.0. Copyright 2006 Vector Networks Ltd and MetaQuest Software Inc. All rights reserved.

Evaluator s Guide. PC-Duo Enterprise HelpDesk v5.0. Copyright 2006 Vector Networks Ltd and MetaQuest Software Inc. All rights reserved. Evaluator s Guide PC-Duo Enterprise HelpDesk v5.0 Copyright 2006 Vector Networks Ltd and MetaQuest Software Inc. All rights reserved. All third-party trademarks are the property of their respective owners.

More information

Access Queries (Office 2003)

Access Queries (Office 2003) Access Queries (Office 2003) Technical Support Services Office of Information Technology, West Virginia University OIT Help Desk 293-4444 x 1 oit.wvu.edu/support/training/classmat/db/ Instructor: Kathy

More information

3.GETTING STARTED WITH ORACLE8i

3.GETTING STARTED WITH ORACLE8i Oracle For Beginners Page : 1 3.GETTING STARTED WITH ORACLE8i Creating a table Datatypes Displaying table definition using DESCRIBE Inserting rows into a table Selecting rows from a table Editing SQL buffer

More information

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery PHP Debugging Draft: March 19, 2013 2013 Christopher Vickery Introduction Debugging is the art of locating errors in your code. There are three types of errors to deal with: 1. Syntax errors: When code

More information

2Creating Reports: Basic Techniques. Chapter

2Creating Reports: Basic Techniques. Chapter 2Chapter 2Creating Reports: Chapter Basic Techniques Just as you must first determine the appropriate connection type before accessing your data, you will also want to determine the report type best suited

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

How to get the most out of Windows 10 File Explorer

How to get the most out of Windows 10 File Explorer How to get the most out of Windows 10 File Explorer 2 Contents 04 The File Explorer Ribbon: A handy tool (once you get used to it) 08 Gain a new perspective with the Group By command 13 Zero in on the

More information

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

More information

Data Tool Platform SQL Development Tools

Data Tool Platform SQL Development Tools Data Tool Platform SQL Development Tools ekapner Contents Setting SQL Development Preferences...5 Execution Plan View Options Preferences...5 General Preferences...5 Label Decorations Preferences...6

More information

VHDL Test Bench Tutorial

VHDL Test Bench Tutorial University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory VHDL Test Bench Tutorial Purpose The goal of this tutorial is to demonstrate how to automate

More information

Many home and small office networks exist for no

Many home and small office networks exist for no C H A P T E R Accessing and Sharing Network Resources Many home and small office networks exist for no other reason than to share a broadband Internet connection. The administrators of those networks attach

More information

Designing and Implementing Forms 34

Designing and Implementing Forms 34 C H A P T E R 34 Designing and Implementing Forms 34 You can add forms to your site to collect information from site visitors; for example, to survey potential customers, conduct credit-card transactions,

More information

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number

More information

Tips and Tricks Guide tm. Windows Administration. Don Jones and Dan Sullivan

Tips and Tricks Guide tm. Windows Administration. Don Jones and Dan Sullivan Tips and Tricks Guide tm To tm Windows Administration Don Jones and Dan Sullivan Tip, Trick, Technique 5: Evaluating Windows Server Backup... 1 Installing Windows Server Backup... 1 Using Windows Server

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

State of Michigan Data Exchange Gateway. Web-Interface Users Guide 12-07-2009

State of Michigan Data Exchange Gateway. Web-Interface Users Guide 12-07-2009 State of Michigan Data Exchange Gateway Web-Interface Users Guide 12-07-2009 Page 1 of 21 Revision History: Revision # Date Author Change: 1 8-14-2009 Mattingly Original Release 1.1 8-31-2009 MM Pgs 4,

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1 MAS 500 Intelligence Tips and Tricks Booklet Vol. 1 1 Contents Accessing the Sage MAS Intelligence Reports... 3 Copying, Pasting and Renaming Reports... 4 To create a new report from an existing report...

More information

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt Lesson Notes Author: Pamela Schmidt Tables Text Fields (Default) Text or combinations of text and numbers, as well as numbers that don't require calculations, such as phone numbers. or the length set by

More information

AliOffice 2.0 Installation Guide

AliOffice 2.0 Installation Guide January 25, 2012 AliOffice 2.0 Installation Guide Overview This document contains instructions for installing AliOffice and readying the application for the completion and submission of compliance evaluations.

More information

JAMS 6.X Client Features 3. Working with Jobs 4-5. Submitting Jobs Manually 6-7. Working with Setups 8-9. Working with Views 10-14

JAMS 6.X Client Features 3. Working with Jobs 4-5. Submitting Jobs Manually 6-7. Working with Setups 8-9. Working with Views 10-14 Table of Contents JAMS 6.X Client Features 3 Working with Jobs 4-5 Submitting Jobs Manually 6-7 Working with Setups 8-9 Working with Views 10-14 Working with Folders 15-16 Viewing Job History 17-18 Working

More information

ShoreTel Active Directory Import Application

ShoreTel Active Directory Import Application INSTALLATION & USER GUIDE ShoreTel Active Directory Import Application ShoreTel Professional Services Introduction The ShoreTel Active Directory Import application creates, updates, and removes System

More information

Sage Abra SQL HRMS Reports. User Guide

Sage Abra SQL HRMS Reports. User Guide Sage Abra SQL HRMS Reports User Guide 2010 Sage Software, Inc. All rights reserved. Sage, the Sage logos, and the Sage product and service names mentioned herein are registered trademarks or trademarks

More information

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input

More information

Creating Basic Excel Formulas

Creating Basic Excel Formulas Creating Basic Excel Formulas Formulas are equations that perform calculations on values in your worksheet. Depending on how you build a formula in Excel will determine if the answer to your formula automatically

More information

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro, to your M: drive. To do the second part of the prelab, you will need to have available a database from that folder. Creating a new

More information

This document is provided "as-is". Information and views expressed in this document, including URLs and other Internet Web site references, may

This document is provided as-is. Information and views expressed in this document, including URLs and other Internet Web site references, may This document is provided "as-is". Information and views expressed in this document, including URLs and other Internet Web site references, may change without notice. Some examples depicted herein are

More information

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration

Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration Lab 4.4 Secret Messages: Indexing, Arrays, and Iteration This JavaScript lab (the last of the series) focuses on indexing, arrays, and iteration, but it also provides another context for practicing with

More information

Track User Password Expiration using Active Directory

Track User Password Expiration using Active Directory Track User Password Expiration using Active Directory Jeff Hicks 1. 8 0 0. 8 1 3. 6 4 1 5 w w w. s c r i p t l o g i c. c o m / s m b I T 2011 ScriptLogic Corporation ALL RIGHTS RESERVED. ScriptLogic,

More information

ShoreTel Active Directory Import Application

ShoreTel Active Directory Import Application INSTALLATION & USER GUIDE ShoreTel Active Directory Import Application ShoreTel Professional Services Introduction The ShoreTel Active Directory Import Application allows customers to centralize and streamline

More information

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10 Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

More information

In the same spirit, our QuickBooks 2008 Software Installation Guide has been completely revised as well.

In the same spirit, our QuickBooks 2008 Software Installation Guide has been completely revised as well. QuickBooks 2008 Software Installation Guide Welcome 3/25/09; Ver. IMD-2.1 This guide is designed to support users installing QuickBooks: Pro or Premier 2008 financial accounting software, especially in

More information

Microsoft Access 3: Understanding and Creating Queries

Microsoft Access 3: Understanding and Creating Queries Microsoft Access 3: Understanding and Creating Queries In Access Level 2, we learned how to perform basic data retrievals by using Search & Replace functions and Sort & Filter functions. For more complex

More information

SecureAssess Local. Install Guide. www.btl.com. Release 9.0

SecureAssess Local. Install Guide. www.btl.com. Release 9.0 SecureAssess Local Install Guide Release 9.0 Document 1.0 15.11.10 www.btl.com Disclaimer Whilst every effort has been made to ensure that the information and content within this user manual is accurate,

More information

Managing Users and Identity Stores

Managing Users and Identity Stores CHAPTER 8 Overview ACS manages your network devices and other ACS clients by using the ACS network resource repositories and identity stores. When a host connects to the network through ACS requesting

More information

Action settings and interactivity

Action settings and interactivity Interactivity in Powerpoint Powerpoint includes a small set of actions that can be set to occur when the user clicks, or simply moves the cursor over an object. These actions consist of links to other

More information

RIT Installation Instructions

RIT Installation Instructions RIT User Guide Build 1.00 RIT Installation Instructions Table of Contents Introduction... 2 Introduction to Excel VBA (Developer)... 3 API Commands for RIT... 11 RIT API Initialization... 12 Algorithmic

More information

Authoring for System Center 2012 Operations Manager

Authoring for System Center 2012 Operations Manager Authoring for System Center 2012 Operations Manager Microsoft Corporation Published: November 1, 2013 Authors Byron Ricks Applies To System Center 2012 Operations Manager System Center 2012 Service Pack

More information

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code

1 Introduction. 2 An Interpreter. 2.1 Handling Source Code 1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons

More information

Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS...

Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS... Access 2010: Creating Queries Table of Contents INTRODUCTION TO QUERIES... 2 QUERY JOINS... 2 INNER JOINS... 3 OUTER JOINS... 3 CHANGE A JOIN PROPERTY... 4 REMOVING A JOIN... 4 CREATE QUERIES... 4 THE

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved. 1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

AN INTRODUCTION TO UNIX

AN INTRODUCTION TO UNIX AN INTRODUCTION TO UNIX Paul Johnson School of Mathematics September 24, 2010 OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From

More information

Introduction to PowerShell by Guy Thomas

Introduction to PowerShell by Guy Thomas Introduction to PowerShell by Guy Thomas Chapter Headings: Windows PowerShell Our Mission... 3 Windows PowerShell Introduction... 4 GS 1: Download your copy of PowerShell... 9 GS 2: Three Ways to Execute

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

FileMaker 14. ODBC and JDBC Guide

FileMaker 14. ODBC and JDBC Guide FileMaker 14 ODBC and JDBC Guide 2004 2015 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker and FileMaker Go are trademarks of FileMaker,

More information

Website Development Komodo Editor and HTML Intro

Website Development Komodo Editor and HTML Intro Website Development Komodo Editor and HTML Intro Introduction In this Assignment we will cover: o Use of the editor that will be used for the Website Development and Javascript Programming sections of

More information

Creating and Using Databases with Microsoft Access

Creating and Using Databases with Microsoft Access CHAPTER A Creating and Using Databases with Microsoft Access In this chapter, you will Use Access to explore a simple database Design and create a new database Create and use forms Create and use queries

More information

Getting Started with Command Prompts

Getting Started with Command Prompts Getting Started with Command Prompts Updated March, 2013 Some courses such as TeenCoder : Java Programming will ask the student to perform tasks from a command prompt (Windows) or Terminal window (Mac

More information

PowerShell for Dummies

PowerShell for Dummies PowerShell for Dummies Project: Supervision Targeted Product: GSX Monitor & Analyzer Content Introduction: A Bit of History... 3 Starting with PowerShell... 4 Prerequisites... 5 Exchange Management Shell...

More information

The Windows PowerShell Owner s Manual: Version 2.0. Jean Ross and Greg Stemp Microsoft Communications Server UA

The Windows PowerShell Owner s Manual: Version 2.0. Jean Ross and Greg Stemp Microsoft Communications Server UA The Windows PowerShell Owner s Manual: Version 2.0 Jean Ross and Greg Stemp Microsoft Communications Server UA This document is provided as-is. Information and views expressed in this document, including

More information

Microsoft Excel Tips & Tricks

Microsoft Excel Tips & Tricks Microsoft Excel Tips & Tricks Collaborative Programs Research & Evaluation TABLE OF CONTENTS Introduction page 2 Useful Functions page 2 Getting Started with Formulas page 2 Nested Formulas page 3 Copying

More information

Database Applications Microsoft Access

Database Applications Microsoft Access Database Applications Microsoft Access Lesson 4 Working with Queries Difference Between Queries and Filters Filters are temporary Filters are placed on data in a single table Queries are saved as individual

More information

Exercise 4 Learning Python language fundamentals

Exercise 4 Learning Python language fundamentals Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also

More information

Teamstudio USER GUIDE

Teamstudio USER GUIDE Teamstudio Software Engineering Tools for IBM Lotus Notes and Domino USER GUIDE Edition 30 Copyright Notice This User Guide documents the entire Teamstudio product suite, including: Teamstudio Analyzer

More information

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com Essential SQL 2 Essential SQL This bonus chapter is provided with Mastering Delphi 6. It is a basic introduction to SQL to accompany Chapter 14, Client/Server Programming. RDBMS packages are generally

More information

The Center for Teaching, Learning, & Technology

The Center for Teaching, Learning, & Technology The Center for Teaching, Learning, & Technology Instructional Technology Workshops Microsoft Excel 2010 Formulas and Charts Albert Robinson / Delwar Sayeed Faculty and Staff Development Programs Colston

More information

Administration Guide. BlackBerry Resource Kit for BES12. Version 12.3

Administration Guide. BlackBerry Resource Kit for BES12. Version 12.3 Administration Guide BlackBerry Resource Kit for BES12 Version 12.3 Published: 2015-10-30 SWD-20151022151109848 Contents Compatibility with other releases...4 BES12 Log Monitoring Tool... 5 Specifying

More information