10 Inventory expert

 

This chapter covers:

  • Querying Active Directory for enabled computers
  • Quickly checking whether computers are online
  • Checking a variable for multiple different values without nested if/else statements
  • Gathering information from remote computers
  • Outputting arrays to CSVs

If you’ve been in the IT industry long, you realize there is a lot of data to manage.  Each computer has dozens of components and characteristics that are valuable.  If a new virus, for example, affects only specific versions of Windows 10 it can be a mad dash to figure out exactly how many computers in your company are at risk and need to be mitigated and accounted for. 

Hard Drive space can fill up rapidly, and critical data may be irrevocably lost once a drive is full.  As PCs age, you may need to upgrade RAM to keep the system functional.  Serial numbers are often used by vendors for support, and for remote computers, in the past, gathering all of the required data meant a phone call at best and perhaps even a trip to the location at worst to get this information and more.  Worse, if you didn’t gather all of the data or recorded it incorrectly this could mean a costly re-work.

Wouldn’t it be nice if we could simply run a script and gather all of this information and more from any computer, a list of computers (say all of the PCs in a particular geographic location), or all of the active computers on your domain?  This is exactly the need we’re going to address in this very chapter!

10.1 Project Code

10.2 The Switch Statement

10.2.1 Structure of the Switch Statement

10.2.2 Selecting the first character for switches

10.2.3 How do we use this in our Tiny PowerShell Script?

10.3 Test-Connection

10.3.1 The structure of the Test-Connection cmdlet

10.3.2 How do we use this in our Tiny PowerShell Script?

10.4 Get-CimInstance

10.4.1 Get-CimClass

10.4.2 Get-CimInstance cmdlet structure

10.4.3 How do we use this in our Tiny PowerShell Script?

10.5 Hashtables

10.5.1  Hashtable structure

10.5.2 Benefits of using a hashtable in PowerShell

10.5.3 How do we use this in our Tiny PowerShell Project?

10.6 Export-CSV

10.6.1 Structure of the Export-CSV cmdlet

10.6.2 How do we use this in our Tiny PowerShell Script?