LAB Module 4
LAB Module 4
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
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 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.
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.
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.
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.
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 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.
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.