WIN201A-EN-I-02.1/2.2 : Cmd.exe vs PowerShell.
exe/Command Discovery
using Windows PowerShell 4.0
Objective
The objectives of this lab are to learn how to:
• Launch the PowerShell console and Integrated Scripting Environment (ISE)
• Discover and Execute PowerShell commands
Scenario
NOTE: These exercises use many Windows PowerShell commands. You can type these commands into the
Windows PowerShell Integrated Scripting Environment (ISE) or the Windows PowerShell console. For some
exercises, you can load pre-typed lab files into the Windows PowerShell ISE, allowing you to select and execute
individual commands. Each lab has its own folder under C:\PShell\Labs\ on WIN8-WS.
Some exercises in this workshop may require running the Windows PowerShell console or ISE as an elevated user
(Run as Administrator).
We recommend that you connect to the virtual machines (VMs) for these labs through Remote Desktop rather than
connecting through the Hyper-V console. This allows you to use copy and paste between VMs and the host
machine. If you are using the online hosted labs, then you are already using Remote Desktop.
Virtual Machines
1. 2012R2-DC
2. 2012R2-MS
3. WIN8-WS
Exercise 1 : Videos
Please use this link to play the videos at any time.
1. Discover PowerShell Commands Video
Click the Video icon to the left to view the video.
Exercise 2 : Cmd.exe vs PowerShell.exe
In this exercise you will:
• Execute Windows PowerShell from within the Windows command prompt
• Launch Windows PowerShell’s own command console and ISE
• Use basic Windows PowerShell Cmdlets to get help
Scenario:
Traditionally Microsoft Windows has included the command prompt (cmd.exe) to execute commands. Windows
PowerShell provides backward compatibility to continue to use these legacy commands, or to use Windows
PowerShell’s native commands (Cmdlets).
1. Activate Windows Logon
To activate the Ctrl + Alt + Delete sequence, select Ctrl + Alt + Delete from the Commands menu in the
upper-right hand corner of the screen to bring up the logon page.
2. Sign In to WIN8-WS
Sign in to WIN8-WS as Contoso\Administrator with the following password: PowerShell4 and press
Enter.
Note: You may also use the Commands menu to automatically paste the virtual machine default
Password (PowerShell4).
3. Run cmd.exe as Administrator
Launch cmd.exe. Point to the lower left corner of the screen, and right-click the Start-button. Then select
Command Prompt (Admin).
This is something that you you should know.. But may not
4. Use Cmdlets
Type the commands listed in the Knowledge [Head icon] box.
cd c:\windows
dir
cls
ipconfig
ping 2012R2-MS
net share
5. Launch PowerShell.exe from cmd.exe
Launch PowerShell.exe from within cmd.exe, by typing the following command: PowerShell
6. Use PowerShell Commands
Type the commands listed in the Knowledge box.
cd c:\windows
dir
cls
ipconfig
ping 2012R2-MS
net share
7. Exit Windows PowerShell
To leave Windows PowerShell, type: Exit
8. Exit Windows Command Prompt
Type: exit again, to close the Windows Command Prompt console.
9. Launch Windows PowerShell
Click the PowerShell icon on the taskbar. This will launch the blue Windows PowerShell console.
10. Run PowerShell Cmdlets
Type the Windows PowerShell commands listed in the Knowledge box.
Set-Location C:\Windows
Get-ChildItem
Clear-Host
Get-NetIPConfiguration
Get-NetIPConfiguration -Detailed
Test-Connection 2012R2-MS
Get-SMBShare
11. Notice Cmdlet Names
Notice the regularity of the Cmdlet names. This makes it easy to understand what any given Windows
PowerShell Cmdlet will do.
What do you think the Cmdlet name would be to get help? Write the command down then try it in
Windows PowerShell.
12. Question: List of Commands
What do you think the Cmdlet would be to get a list of commands? Write it down then try it in
PowerShell.
13. Exit Windows PowerShell
Close the Windows PowerShell console by typing: Exit
14. Run PowerShell ISE as Administrator
Right-click the PowerShell icon on the taskbar and select the Run ISE as Administrator option. This will
launch the Windows PowerShell Integrated Scripting Environment. Click the Knowledge icon for more
information.
NOTE: The Windows PowerShell Integrated Scripting Environment (ISE) is a host application for
Windows PowerShell.
In Windows PowerShell ISE, you can run commands and write, test, and debug scripts in a single
Windows-based graphic user interface with multiline editing, tab completion, syntax coloring,
selective execution, context-sensitive help, and support for right-to-left languages.
You can use menu items and keyboard shortcuts to perform many of the same tasks that you
would perform in the Windows PowerShell console.
15. View IntelliSense List
Type the following PowerShell command in the blue command pane: Get-
Wait for the IntelliSense drop down list to appear.
16. Use IntelliSense to Select Cmdlet
Type the letters: pro and Watch as IntelliSense filters the list of Cmdlets. Press Enter to select the
highlighted Cmdlet.
17. Execute Cmdlet
Press Enter to execute the Cmdlet.
18. View Currently Running Processes
Type the following command: Get-Process –Name and then press the spacebar. A list of currently
running processes will appear in the drop down list.
19. Select spoolsv Process
Select the process spoolsv and press Enter.
Congratulations!
You have successfully:
• Executed Windows PowerShell from within the Windows command prompt
• Launched Windows PowerShell’s own command console and ISE
• Used basic Windows PowerShell Cmdlets to get help
Click Continue to advance to the next exercise.
Exercise 3 : Command Discovery
In this exercise you will:
• Explore Windows PowerShell Cmdlets
• Use Windows PowerShell Help Cmdlet
Scenario:
Windows PowerShell contains thousands of built-in commands, known as Cmdlets. The ability to search for a relevant
command is vital.
1. Auto Complete Command Name
Type the following in the current Windows PowerShell ISE command pane, then press the TAB key to
auto complete the Command name: Get-Co and then press Enter to execute the Get-Command Cmdlet.
2. Question: How Many Cmdlets Returned
Type the same text: Get-Co and press the TAB key multiple times. How many Cmdlets appear?
3. View Service Command
Press the Escape button on your keyboard to clear the command prompt. Now type the following
command and press Enter: Get-Command *service
4. Record Returned Command Names
Write the command names returned. (Click the Knowledge icon for more information)
Get-SMServerService
Get-Service
New-Service
Restart-Service
Resume-Service
Set-Service
Start-Service
Stop-Service
Suspend-Service
5. Type Cmdlets
Type the commands listed in the Knowledge box.
Get-Command –Verb Suspend
Get-Command –Noun Computer
Get-Command –Name Get-Service
6. Question: List all Commands with Get
List all commands with the verb Get. Write down the command used to achieve this.
7. Run Help Cmdlet
Type the following command: Get-Help
8. Question: Display Online Help
After reading the output, how would you display the online help for the Get-Service Cmdlet? Write
down the command.
NOTE: The VM must be internet-connected for the command to succeed.
9. Examine Help for Cmdlets
Type the commands listed in the Knowledge box and examine the outputs.
Get-Help Get-Service
Get-Help Get-Service –Examples
Help Get-Service -Examples
Get-Help Get-Service –Full
Get-Help Get-Service -ShowWindow
10. View Get-Service Help Settings
The last command opens a new dialog window that displayed help for the Get-Service cmdlet. Click the
Settings button.
11. Verify Whole Word Checked
Verify that the Whole Word box is checked, then click OK.
12. Find: Include
Type the word: Include in the Find text box. Note the yellow highlights that appear and find the help for
the –Include Parameter
13. Question: -Include Parameter
Does the –Include parameter accept pipeline input? Does this parameter accept wildcard characters?
14. Close Get-Service Help Dialog
Close the Get-Service Help dialog.
15. Close All Windows
Close all open windows.
Congratulations!
You have successfully:
• Explored Windows PowerShell Cmdlets
• Used Windows PowerShell Help Cmdlet
Click Continue to advance to the next exercise.
Exercise 4 : Optional Full Course Videos
Full Course Videos
1. Click here, then see Task Text for Link to Course
Click the idea light bulb icon to the left to play the course.
To play the full course, click the following link: PowerShell 4 for the IT Pro, Part 1