April 2024
Beginner to intermediate
336 pages
8h 51m
English
Remember back in chapter 8 when we created our initial design for Get-MachineInfo? So far, we’re querying for some information but not for everything we want it to do. That was a deliberate decision we made so that you could get some structure around the tool first. We’ve also held off because once you start querying a bunch of information, you need to take a specific approach to combine it, and we wanted to tackle that approach in a single chapter.
Right now, the “functional” part of the tool looks like this:
# Query data
$Session = New-CIMSession -ComputerName SRV1
$os = Get-CimInstance -ClassName Win32_OperatingSystem `
-CimSession $session
# Close session
$session | Remove-CimSession
# Output data
$os ...