7.3.11 Lab - Using Windows PowerShell
7.3.11 Lab - Using Windows PowerShell
Objectives
The objective of the lab is to explore some of the functions of PowerShell.
Part 1: Access PowerShell console.
Part 2: Explore Command Prompt and PowerShell commands.
Part 3: Explore cmdlets.
Part 4: Explore the netstat command using PowerShell.
Part 5: Empty recycle bin using PowerShell.
Background / Scenario
PowerShell is a powerful automation tool. It is both a command console and a scripting language. In this lab,
you will use the console to execute some of the commands that are available in both the command prompt
and PowerShell. PowerShell also has functions that can create scripts to automate tasks and work together
with the Windows Operating System.
Required Resources
= 1 Windows PC with PowerShell installed and internet access
Instructions
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 10
Lab - Using Windows PowerShell
Question:
b. Try another command that you have used in the command prompt, such as ping, cd, and ipconfig.
What are the results?
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 10
Lab - Using Windows PowerShell
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 10
Lab - Using Windows PowerShell
CommandTypeNameVersionSource
----------------------------
Aliasdir -> Get-ChildItem
Question:
b. For more detailed information about cmdlets, perform an internet search for Microsoft powershell
cmdlets.
c. Close the Command Prompt window when done.
NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval]
-a Displays all connections and listening ports.
-b Displays the executable involved in creating each connection or listening port.
In some cases well-known executables host multiple independent components, and in
these cases the sequence of components involved in creating the connection or
listening port is displayed. In this case the executable name is in [] at the bottom,
on top is the component it called, and so forth until TCP/IP was reached. Note that
this option can be time-consuming and will fail unless you have sufficient
permissions.
<some output omitted>
b. To display the routing table with the active routes, enter netstat -r at the prompt.
PS C:\Users\CyberOpsUser> netstat -r
===========================================================================
Interface List
3...08 00 27 a0 c3 53 ......Intel(R) PRO/1000 MT Desktop Adapter
10...08 00 27 26 c1 78 ......Intel(R) PRO/1000 MT Desktop Adapter #2
1...........................Software Loopback Interface 1
===========================================================================
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 10
Lab - Using Windows PowerShell
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.5 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
169.254.0.0 255.255.0.0 On-link 169.254.181.151 281
169.254.181.151 255.255.255.255 On-link 169.254.181.151 281
169.254.255.255 255.255.255.255 On-link 169.254.181.151 281
192.168.1.0 255.255.255.0 On-link 192.168.1.5 281
192.168.1.5 255.255.255.255 On-link 192.168.1.5 281
192.168.1.255 255.255.255.255 On-link 192.168.1.5 281
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 192.168.1.5 281
224.0.0.0 240.0.0.0 On-link 169.254.181.151 281
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 192.168.1.5 281
255.255.255.255 255.255.255.255 On-link 169.254.181.151 281
===========================================================================
Persistent Routes:
None
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 10
Lab - Using Windows PowerShell
c. Open and run a second PowerShell with elevated privileges. Click Start. Search for PowerShell and right-
click Windows PowerShell and select Run as administrator. Click Yes to allow this app to make
changes to your device.
d. The netstat command can also display the processes associated with the active TCP connections. Enter
the netstat -abno at the prompt.
PS C:\Windows\system32> netstat -abno
Active Connections
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 10
Lab - Using Windows PowerShell
e. Open the Task Manager. Navigate to the Details tab. Click the PID heading so the PID are in order.
f. Select one of the PIDs from the results of netstat -abno. PID 756 is used in this example.
g. Locate the selected PID in the Task Manager. Right-click the selected PID in the Task Manager to open
the Properties dialog box for more information.
Question:
What information can you get from the Details tab and the Properties dialog box for your selected PID?
PID 5440 is associated with Code.exe process. The user for this process is jhero not
indicated and it is using 1884K of memory.
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 10
Lab - Using Windows PowerShell
Confirm
Are you sure you want to perform this action?
Performing the operation "Clear-RecycleBin" on target "All of the contents of the
Recycle Bin".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is
"Y"): y
Question:
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 8 of 10
Lab - Using Windows PowerShell
Reflection Question
PowerShell was developed for task automation and configuration management. Using the internet, research
commands that you could use to simplify your tasks as a security analyst. Record your findings.
As a cybersecurity student, I understand PowerShell's purpose in task automation and
configuration management, and I recognize its potential to streamline security analysis. To simplify my
tasks, I've researched commands like Get-EventLog for log analysis, Get-Process and Stop-Process for
process monitoring, Get-FileHash for file integrity checks, Get-NetTCPConnection for network analysis,
and Get-ExecutionPolicy for managing script execution. These commands are crucial for quickly
identifying and responding to security incidents, as well as for automating repetitive tasks like log review
and system auditing.
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 9 of 10
Lab - Using Windows PowerShell
2017 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 10 of 10