0% found this document useful (0 votes)
3 views

Lab Module 2

The document provides lab instructions for using the formatting subsystem in PowerShell, including exercises on displaying calculated properties, limiting displayed columns, and viewing objects via HTML. Each exercise outlines specific tasks to retrieve and format data, such as processes and services, for better visualization and analysis. The lab is designed for system administrators to assist developers by presenting data in a user-friendly manner.

Uploaded by

shrikantnpar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab Module 2

The document provides lab instructions for using the formatting subsystem in PowerShell, including exercises on displaying calculated properties, limiting displayed columns, and viewing objects via HTML. Each exercise outlines specific tasks to retrieve and format data, such as processes and services, for better visualization and analysis. The lab is designed for system administrators to assist developers by presenting data in a user-friendly manner.

Uploaded by

shrikantnpar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lab Instructions: Understanding and Using the

Formatting System
Module 2

Contents:
Lab: Using the Formatting Subsystem
Exercise 1: Displaying Calculated Properties
Exercise 2: Displaying a Limited Number of Columns
Exercise 3: Displaying All Properties and Values of Objects
Exercise 4: Viewing Objects via HTML
Exercise 5: Displaying a Limited Number of Properties
Exercise 6: Displaying Objects Using Different Formatting
Exercise 7: Displaying a Sorted List of Objects
Lab: Using the Formatting Subsystem
Estimated time: 20 minutes
You are a system administrator for a company and work with a team of developers.Recently,
some users have complained about an in-house developed application. The developers have
asked you to monitor the processes associated with the troubled application and let them have
easy access to the data. You have decided to provide them with that information via an HTML-
based page so they can easily view the information in a Web browser. You also want to
customize your view of this information as you view it in the PowerShell console.

Lab Setup
For this lab, you will use the available virtual machine environment. Before you begin the lab,
you must:
1. Start the AD virtual machine. You don’t need to log on but wait until the boot process is
complete.
• Username: CONTOSO\administrator
• Password: Pa$$w0rd
2. Open a Windows PowerShell session as Administrator.
Exercise 1: Displaying Calculated Properties

Scenario
You need to check the status of processes on your server, and you want to display their status
and also show custom properties in a table format.The main tasks for this exercise are as follows:
1. Retrieve a list of processes.
2. Display a table of objects.
3. Select the properties to display.
4. Use calculated properties to show a custom property.

� Task 1: Retrieve a list of processes


• Open Windows PowerShell and retrieve a list of running processes.

� Task 2: Display a table of objects


• Show the list of running processes formatted as a table.

� Task 3: Select the properties to display


• Show the list of running processes formatted as a table showing only the CPU, Id, and
ProcessName values.

� Task 4: Use calculated properties to show a custom property


• Show the list of running processes formatted as a table showing the CPU, Id, ProcessName
values, and a custom property named TotalMemory, which is the sum of the physical and
virtual memory used for each process.

Hint: Just add the values together—don’t be concerned if one is displayed in KB and
the other in MB.
Results: After this exercise, you will have displayed the CPU, ID and ProcessName values of all
the running processes. You also will have created a custom property adding the physical and
virtual memory using calculated properties.
Exercise 2: Displaying a Limited Number of Columns
Scenario
You need to display a list of services on your systems. You need to filter out some of the
columns that you don’t need when reviewing the status of the services.The main tasks for this
exercise are as follows:
1. Retrieve a list of services.
2. Display a specific number of columns from a collection of objects.

� Task 1: Retrieve a list of services


• Retrieve a list of services.

� Task 2: Display a specific number of columns from a collection of objects


• Retrieve a list of services and display only the Status and Name properties.

Results: After this exercise, you will have displayed a specific number of columns from all the
installed services instead of displaying all their default properties.

Exercise 3: Displaying All Properties and Values of Objects


Scenario
You often retrieve a list of processes from your systems and need to display all the properties
and values of the services and not just the default values normally display.The main tasks for this
exercise are as follows:
1. Retrieve a list of processes.
2. Display every property and value for all the objects.

� Task 1: Retrieve a list of processes


• Retrieve a list of processes.

� Task 2: Display every property and value for all the objects
• Retrieve a list of processes and display all their properties and values.

Results: After this exercise, you will have displayed all of the properties of all of the running
processes instead of displaying only their default properties.

Exercise 4: Viewing Objects via HTML


Scenario
You have been asked by the development team to post a log of entries from one server’s
application event log. You have decided to automate the gathering of the information and are
posting it on an internal Web site for the developers to review.The main tasks for this exercise
are as follows:
1. Retrieve a list of event log entries.
2. Convert a list of event log entries to HTML.
3. Use a custom title for an HTML page.
4. View an HTML page in the default Web browser.

� Task 1: Retrieve a list of event log entries


• Retrieve the newest 25 events from the Windows Application event log.

� Task 2: Convert a list of event log entries to HTML


• Retrieve the newest 25 events from the Windows Application event log and convert the events
as HTML and save the results to a file.

� Task 3: Use a custom title for an HTML page


• Retrieve the newest 25 events from the Windows Application event log and convert the events
as HTML file while changing its title to Last 25 events and save the results to a file.

� Task 4: View an HTML page in the default Web browser


• View the resulting file from the previous task in the default Web browser (Hint: use Invoke-
Item).

Results: After this exercise, you will have displayed a customized HTML page that contains a
listing of the 25 newest events from the Windows Application event log.

Exercise 5: Displaying a Limited Number of Properties


Scenario
You need to review the length of certain files in a particular directory and want to use
PowerShell to accomplish this task. The main tasks for this exercise are as follows:
1. Display a list of files from a selected folder.
2. Display a table with several different file properties.

� Task 1: Display a list of files from a selected folder


• Retrieve a list of all the files that start with au and end with .dll from the
C:\Windows\System32 directory.

� Task 2: Display a table with several different file properties


• Retrieve a list of all the files of that start with au and end with .dll from the
C:\Windows\System32 directory and display the Name, Length and Extension properties using
a table.

Results: After this exercise, you will have displayed a table containing the Name, Length and
Extension properties of all the files in C:\Windows\System32 that start with au and have the
extension .dll.

Exercise 6: Displaying Objects Using Different Formatting


Scenario
You often use PowerShell to verify the status of processes and services and want to know how to
change the way that the information is displayed in the console. The main tasks for this exercise
are as follows:
1. Retrieve a list of services.
2. Display a table showing only a few specific properties.
3. Display a table by eliminating any empty spaces between columns.

� Task 1: Retrieve a list of services


• Retrieve a list of services.

� Task 2: Display a table showing only a few specific properties


• Retrieve a list of services and display only the DisplayName, Status and DependentServices
properties using a table.

� Task 3: Display a table by eliminating any empty spaces between columns


• Retrieve a list of services and display only the DisplayName, Status and DependentServices
properties using a table and eliminating any empty spaces between columns.

Results: After this exercise, you will have displayed a table of all the installedservices by
displaying only the DisplayName, Status, and DependentServices properties. You have also
removed any empty spaces between each column.

Exercise 7: Displaying a Sorted List of Objects


Scenario
You use PowerShell to view the status of processes and services and want to modify how some
of the columns display data and even possibly create new customized columns.The main tasks
for this exercise are as follows:
1. Retrieve a list of services.
2. Display a table while sorting a specific property.

� Task 1: Retrieve a list of services


• Retrieve a list of services.

� Task 2: Display a table while sorting a specific property


• Retrieve a list of services and display a table showing the services by sorting on the Status
property.

Results: After this exercise, you will have displayed a table of the installed services sorted by
their Status property.

You might also like