Using Windows PowerShell and the PowerShell ISE
Windows PowerShell is an extensible version of the command prompt. It is integrated with the Microsoft .NET Framework, which gives it extensive capabilities well beyond the command prompt. Windows 7 comes with Windows PowerShell 2.0 installed (the same version that's installed on Windows Server 2008 R2).
The PowerShell commands can be used to perform and automate many administrative tasks such as managing services, managing event logs, modifying the Registry, and interacting with Windows Management Instrumentation. PowerShell was designed with scripting in mind, so you'll find that you can create elegant scripts that can automate many of your administrative tasks.
One of the challenges with PowerShell is that it is so rich in capabilities and features that it can be intimidating. However, you can start using it without understanding everything about it. You can learn as you go.
You'll get the most out of this section if you're able to launch PowerShell, execute the commands, and see them in action You can launch Power- Shell normally or with administrative permissions To launch it with administrative permissions, you'd right-click and select Run As Administrator However, I strongly recommend that you launch it normally unless you need specifically to use administrative permissions (such as when you need to change the execution policy, as shown later in this tutorial)
Just as the command prompt has its own environment, PowerShell too has its own environment. It also has a distinctive look and feel. Launch it and see for yourself by clicking Start → All Programs → Accessories → Windows PowerShell → Windows PowerShell.
While the look and feel are a little different, you can right-click the title bar and have access to the same menu as the command prompt. You can also copy and paste to and from the PowerShell window and enable QuickEdit mode, so this is a little easier. Copy and paste works exactly the same as shown with the command prompt earlier in this tutorial.
In addition to the Windows PowerShell, you'll see the Windows PowerShell ISE, which is the Integrated Scripting Environment (ISE). If you're running a 64-bit system, you'll see the following four choices:
- Windows PowerShell (x86)
- Windows PowerShell ISE (x86)
- Windows PowerShell
- Windows PowerShell IS
I haven't run across any issues using the 64-bit Windows PowerShell and ISE for all my scripts, but if you need to step down to the 32-bit version, you can.
In this tutorial:
- Working with the Command Prompt
- Starting and Ending a Command Prompt Session
- Easy ways to invoke administrator Command Prompt sessions
- Starting Command Prompt at a Particular Folder
- Strings with Spaces Need Quotes
- Cmd.exe vs. Command.com
- Commands Are Not Case Sensitive
- Starting Command Prompt and Running a Command
- Cmd.exe and Other Command Prompts
- Using AutoRun to Execute Commands When Command Prompt Starts
- Using Cmds Command-Line Syntax
- Using Commands
- Type /? for help
- Starting Programs
- Open Windows Explorer at the current Command Prompt folder
- Using File-Name and Folder-Name Completion
- Use a different completion character
- Using Wildcards
- Editing the Command Line
- Using Command Symbols
- The Redirection Symbols
- The Pipe Symbol
- The Command Combination Symbols
- Pausing or Canceling Commands
- Simplifying Command Entry with Doskey Macros
- DOSKEY Saves Typing
- System Variables Identify the Environment
- Viewing Environment Variables
- Modifying Environment Variables
- Predefined Environment Variables
- Customizing Command Prompt Windows
- Setting the Window Size and Position
- Setting the Window Size and Position Visually
- Selecting a Font
- Setting Colors
- Setting Other Options
- Copy and paste in the command prompt window
- Navigating from the command prompt
- Printing a list of filenames
- Commands Use Paths
- Identifying Executables
- Modifying the Path to Executables
- Modifying the Path with the GUI
- Changing the Current Path with CD
- Changing the Current Path with Windows Explorer
- Capturing the Output
- A Sampling of Commands
- Dir
- Copy
- XCopy
- SET
- NET USE
- SystemInfo
- DriverQuery
- Echo
- Advanced Shell Commands
- Creating a Batch File
- Scheduling a Batch File
- Creating Scheduled Tasks with a Script
- Using Windows PowerShell and the PowerShell ISE
- Windows PowerShell ISE
- PowerShell Commands
- Verbs and Nouns
- Sending Output to a Text File
- PowerShell Syntax
- Variables Created with a $ Symbol
- Comparison Operators
- Parentheses, Brackets, and Braces
- Running PowerShell Scripts
- PowerShell Execution Policy
- Changing the Execution Policy
- Looping
- Collections
- Creating a PowerShell Script
- Documenting Scripts
- Using PowerShell Commands
- Getting Help on PowerShell
- Using WMI_Cmdlets
- Getting Details on an Object
- Querying Information on Specific Objects
- Terminate Applications with Win32_process
- Formatting Output with the -f Format Operator
- Filtering the Output with the Where-Object Command
- Using the IF statement
- Using the Switch Statement
- Script Reusability