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

LAB Module 4

The document provides lab instructions for using Windows Management Instrumentation (WMI) in Windows PowerShell, detailing exercises for building a computer inventory, discovering WMI classes, generating logical disk reports, and listing local users and groups. Each exercise includes specific tasks to perform, such as retrieving operating system and BIOS information, filtering logical disks, and generating reports for audit purposes. The lab is designed for systems administrators to manage and monitor domain computers effectively.

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)
2 views

LAB Module 4

The document provides lab instructions for using Windows Management Instrumentation (WMI) in Windows PowerShell, detailing exercises for building a computer inventory, discovering WMI classes, generating logical disk reports, and listing local users and groups. Each exercise includes specific tasks to perform, such as retrieving operating system and BIOS information, filtering logical disks, and generating reports for audit purposes. The lab is designed for systems administrators to manage and monitor domain computers effectively.

Uploaded by

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

Lab Instructions: Windows® Management

Instrumentation
Module 4

Contents:
Lab: Using Windows Management Instrumentation in Windows PowerShell
Exercise 1: Building Computer Inventory
Exercise 2: Discovering WMI Classes and Namespaces
Exercise 3: Generating a Logical Disk Report for All Computers
Exercise 4: Listing Local Users and Groups
Lab: Using Windows Management
Instrumentation in Windows PowerShell
Estimated time: 45 minutes
You work as a systems administrator, and you need to perform certain tasks against the
computers, users, and groups that you manage. You need to check inventory of your computers,
including the operating system versions, service pack versions, and asset tags. Your organization
uses the BIOS serial number as an asset tag tracking system. You need to monitor logical drive
space on multiple remote computers. You also need to generate reports showing local users and
groups on those machines for audit purposes.

Lab Setup
For this lab, you will use the available virtual machine environment. Before you begin the lab,
you must:
1. Start the AD, Windows7 virtual machines, and then log on by using the following credentials:
• Username: NEWHORIZONS\administrator
• Password: Passw0rd
2. Disable the Windows Firewall on AD and Windows7
4. On WINDOWS7, open the Windows PowerShell console. All PowerShell commands will be
run within the Windows PowerShell console.
5. On virtual machine WINDOWS7, create a text file containing the names of all computers in
the domain, one on each line, and save it as C:\users\administrator\documents\computers.txt.

You can either do this in the PowerShell command line if you are able or manually. Its contents
should look as follows:
• AD .Newhorizons.com
• WINDOWS7.Newhorizons.com

Exercise 1: Building Computer Inventory


Scenario
You work as a system administrator. Periodically you need to inventory your domain computers.
The inventory information you require includes the operating system version, the service pack
version, and the asset tag. Your organization uses the BIOS serial number as the asset tag for all
computer systems.

The main tasks for this exercise are carried out on WINDOWS7and are as follows:
1. Retrieve the operating system information for the local computer.
2. Extract specific version information from the operating system object.
3. Retrieve operating system version numbers from the local computer “remotely”.
4. Retrieve operating system version numbers from multiple computers in one command.
5. Export operating system version numbers (both the operating system version and the service
pack version) for multiple computers to a .csv file.
6. Retrieve BIOS serial numbers from multiple computers.
7. Create a custom object for each computer containing all inventory information.
8. Export the results of the last command to a file.

� Task 1: Retrieve the operating system information


1. Get the operating system information from the local computer using
Get-WmiObject with the Win32_OperatingSystem class.
2. Show all properties of the Win32_OperatingSystem object you just retrieved.

� Task 2: Extract version information from the operating system object


1. Show all properties of the Win32_OperatingSystem object with version in their name.
2. Generate a table showing the __SERVER, Version, ServicePackMajorVersion, and
ServicePackMinorVersion properties of the Win32_OperatingSystem object.

Hint: The __SERVER property starts with two underscore characters.

� Task 3: Retrieve the local operating system information “remotely”


1. Repeat the last command, passing the WINDOWS7computer name to the ComputerName
parameter of the Get-WmiObject cmdlet.
2. Show the help information for the ComputerName parameter of the Get-
WmiObject cmdlet. Note that ComputerName accepts an array of strings.

� Task 4: Retrieve the operating system information for all computers


1. Read the list of domain computer names from the computers.txt file in your documents
folder.
2. Modify the last command you ran to retrieve operating system information so that it shows the
information for all computers in the domain.

� Task 5: Export the operating system information for all computers


1. Read the help information for the Select-Object cmdlet.
2. Replace the call to Format-Table in the last Get-WmiObject command pipeline with Select-
Object, maintaining the list of properties that are required.
3. Export the operating system information to a .csv file called Inventory.csv.

� Task 6: Retrieve the BIOS information for all computers


• Retrieve the BIOS information for all computers using the Win32_BIOS class.

� Task 7: Create a custom object for each computer containing all inventory information
1. Read the help information and examples for the Select-Object cmdlet so that you understand
what it is used for and how it works.
2. Combine the operating system version information and BIOS serial numbers into one set of
results using Select-Object.

Hint: This is a complex command. You need to execute Get-WmiObject and use Select-Object to create a
custom column. The expression for that custom column is another call to Get-WmiObject. Refer to the
course material for an example of this complex technique.

� Task 8: Export the inventory report


• Export the results of the last command to a .csv file called Inventory.csv.

Results: After this exercise, you should have successfully retrieved operating system and BIOS
information from all computers in your domain, built custom objects using Select-Object, and
generated an inventory report in a .csv file.

Exercise 2: Discovering WMI Classes and Namespaces


Scenario
You are retrieving computer information remotely using WMI. You need to be able to discover
classes and namespaces on a remote computer so that you can get the data you need.

The main tasks for this exercise are carried out on AD and are as follows:
1. View WMI classes in the default namespace on AD .
2. Find WMI classes using wildcards on AD .
3. Enumerate the list of top-level WMI namespaces on the AD computer.

� Task 1: View WMI classes in the default namespace


1. On AD , read help information for the List parameter in the
Get-WmiObject cmdlet.
2. Get a list of all WMI classes in the default namespace on the AD computer.

� Task 2: Find WMI classes using wildcards


1. Find all WMI classes in the default namespace on AD that contain Printer in their class name.
2. Find all WMI classes in all namespaces on AD that contain Printer in their class name.

� Task 3: Enumerate top-level WMI namespaces


1. Enumerate the top-level WMI namespaces by retrieving WMI objects of class
__NAMESPACE in the root namespace on AD .

Hint: The __NAMESPACE class name begins with two underscore characters.

2. Generate a list of only the top-level WMI namespace names by using Get-
WmiObject with Select-Object.

Hint: Sometimes, a property is a collection of other objects. Select-Object can expand that property into a
list of those objects by using the –ExpandProperty parameter. For example, -ExpandProperty Name
expands the Name property

Results: After this exercise, you should be able to find WMI classes in a specific namespace,
find WMI classes using a wildcard search, and find WMI namespaces on local or remote
computers.

Exercise 3: Generating a Logical Disk Report for All Computers


Scenario
To monitor disk-space usage for computers in your organization, you want to use PowerShell to
retrieve and process WMI information.

The main tasks for this exercise are carried out on WINDOWS7and are as follows:
1. Learn how to discover the WMI class used to retrieve logical disk information.
2. Retrieve logical disk information from the local machine.
3. Apply a server-side filter to filter the logical disks to include only hard disks and gather disk
information for all computers in your domain.
4. Add a calculated value to your report showing percent-free information for hard disks for all
computers in your domain.
5. Learn how to discover information related to WMI classes.

� Task 1: Discover the WMI class used to retrieve logical disk information
• Find all WMI classes in the default namespace on the local machine that contain LogicalDisk
in the class name.

Hint: If you examine the help for Get-WmiObject, you see that the -class parameter is positional and is in
position 2. That means you do not have to type the –class parameter name; you can simply provide a
value, if you place it in the correct position.

� Task 2: Retrieve logical disk information from the local machine


• Get all logical disk drives for the local machine using the Get-WmiObject cmdlet.

� Task 3: Retrieve logical disk information for hard disks in all computers in your domain
1. Read help information for the Filter parameter of the Get-WmiObject cmdlet.
2. Read the list of computer names in your domain from the computers.txt file in your
documents folder.
3. Get all hard disks for all computers in your domain using the Get-WmiObject cmdlet. The
DriveType property value for hard disks is 3. Show the results in a table with the computer
name, device id, and free-space information.

� Task 4: Add a calculated PercentFree value to your report


• Add a calculated parameter to your hard disk table that has the following properties:
• Label: ‘PercentFree’
• Expression: {$_.FreeSpace / $_.Size}

Hint: You have already seen examples of the structure necessary to create a custom or calculated column.
In this task, you are doing the same thing.

Results: After this exercise, you should know how to check logical disk free-space information
using WMI, how to add calculated properties to a report, and how to find related WMI
information from your WMI data.
Exercise 4: Listing Local Users and Groups

Scenario
Corporate regulations require that you maintain an inventory of local users and groups on
computers in your domain for audit purposes.

The main tasks for this exercise are carried out on WINDOWS7and are as follows:
1. Find the WMI classes used to retrieve local users and groups.
2. Generate a report showing all local user accounts and groups from all computers in your
domain. This report should contain the WMI object class to identify the object type as well as the
computer name, user or group name, and SID.

� Task 1: Find the WMI classes used to retrieve local users and groups
1. Search for WMI classes representing local users in the default namespace using Get-
WmiObject.
2. Search for WMI classes representing local groups in the default namespace using Get-
WmiObject.
� Task 2: Generate a local users and groups report
1. Retrieve a list of all local user accounts on the local computer and identify the properties
containing the WMI object class name, the computer name, the user name, and the SID.
2. Retrieve a list of all local groups on the local computer and identify the properties containing
the WMI object class name, the computer name, the user name, and the SID.
3. Read the basic help information for the ForEach-Object cmdlet. Note that ForEach-Object
allows you to process a collection of objects one at a time.
4. Generate a single table showing all local users and groups from all computers in the
computers.txt file that is in your documents folder. Format the table output so that it contains
only the object type, the computer name, the user or group name, and the SID.

Hint: If you want to include two (or more) independent shell commands into a single {script block},
separate the commands by using a semicolon.

Results: After this exercise, you should be able to retrieve local user and group account information from
local and remote computers and generate a report combining this information into a single table.

You might also like