Use PowerShell To Gather Computer Information in Windows
Learn On Demand
Learn On Demand Pro Series

Time
1 hour
Difficulty
Intermediate

This IT Pro Challenges virtual lab teaches learners how to create simple PowerShell scripts. Learners will gain experience using PowerShell to gather system, user, and network information. Skills learned in this lab are valuable in multiple job roles, such as system administrators and security analysts.

Join over 2 million IT and cyber professionals advancing their careers

OR

Sign up with Google

Already have an account? Sign In »

This Learn On Demand Pro Series is part of a Career Path: Become a Penetration Tester

Overview

PowerShell is a cross-platform job automation and configuration administration framework. It contains a command-line shell and a scripting language. PowerShell is created on top of the .NET CLR. This major shift gives completely new tools and techniques for automation.

In this hands-on lab, you will learn how to use PowerShell to gather computer information in Windows. First, you will create a script to gather system information. Next, you will create a script to gather user account information. Finally, you will create a script to gather network information. The other guided and advanced challenges in this series are “Escalate Privileges in Linux” and “Can You Enumerate Network Services By Using Port Scanning in Linux?” respectively.

Understand the Scenario

In this virtual lab, you are a system administrator for a company that is conducting risk assessments. Your job is to determine the types of system configuration information that can be gathered by using Windows PowerShell. To accomplish this task, you will use a default installation of Windows Server 2016.

Gather system information by using Windows PowerShell

Unlike conventional command-line interfaces, PowerShell cmdlets are designed to handle objects. An object is structured data, and the command output always provides extra information that users can utilize if they need it. In this section of the lab, learners will gather system information by using Windows PowerShell. First, they will open the Windows PowerShell ISE, and then select the script arrow above the command prompt window to open the text editor in split-screen mode. Next, in the Windows PowerShell ISE, on the File menu, they will select Save As and enter the name ServerInfo.ps1, and then save it on the Desktop and in the text editor pane, they will enter the command to gather system information. The Windows PowerShell ISE offers you a tab-completion feature. One can use this feature to reduce errors in the command entries and to see which options are available for the Windows PowerShell cmdlet. Next, in the text editor pane, at the end of line 1, they will press Enter twice to move to line 3 of the script to enter the various cmdlet commands to gather BIOS information. Next, in the File Explorer, in C:, they will open ServerInfo.txt and review the content, and then close the file. Finally, they will check and confirm that the C:\ServerInfo.txt file exists, and the ServerInfo.ps1 script exists on the Desktop.

Gather user information by using Windows PowerShell

In this section of the virtual lab, you will gather user information by using Windows Powershell. First, in the Windows PowerShell ISE, you will create a new script, and then save it as AccountInfo.ps1 on the Desktop. In the text editor pane, on line 1, you will enter the cmdlet to enumerate the members of the Administrators group and then select Run Selection. Next, in the text editor pane, at the end of line 1, you will press Enter twice to move to line 3 and enter the cmdlet to retrieve user account information and pipe the output to the Select-Object cmdlet and then select Run Selection. Next, in the text editor pane, you will enter Write-Output above each line, along with a descriptor, and in the text editor pane, at the beginning of line 1, you will press Enter twice and then save the script, and then select Run Script to execute the script. In File Explorer, in C:, you will open AccountInfo.txt and review the content. Finally, you will check and confirm that the C:\AccountInfo.txt file exists, and the AccountInfo.ps1 scripts exist.

Gather network information by using Windows PowerShell

In this section of the virtual lab, learners will gather network information by using Windows PowerShell. First, in the Windows PowerShell ISE, you will create a new script named NetworkInfo.ps1, and then save it on the Desktop, and in the text editor pane, you will enter the cmdlets to report IP addresses on the system. Next, in the text editor pane, you will enter the cmdlets to ping the localhost and the router. Next, you will enter the cmdlet to test a connection to a server by using the HTTP protocol, and then in the text editor pane, you will enter Write-Output above each code block, along with a descriptor. Next, in the text editor pane, at the beginning of line 1, you will press Enter twice and save the script, and then select Run Script to execute the script and then in File Explorer, in C:, you will open NetworkInfo.txt and review the content. Finally, you will check and confirm that the C:\NetworkInfo.txt file exists, and the NetworkInfo.ps1 script exists.

Lab Summary Conclusion

After completing the “Use PowerShell To Gather Computer Information in Windows” virtual lab, you will have accomplished the following:

  • Created a Windows PowerShell script to gather system information.
  • Created a Windows PowerShell script to gather user information.
  • Created a Windows PowerShell script to gather network information.

Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.

LEARN MORE. ACHIEVE MORE.

Follow A Path

Deciphering the essentials to enter a new career is hard, so we did it for you!

Focus on building your skills and take this learn on demand pro series in a guided Career Path.

LEARN MORE. ACHIEVE MORE.

Follow A Path

Deciphering the essentials to enter a new career is hard, so we did it for you!

Focus on building your skills and take this learn on demand pro series in a guided Career Path.