From the course: Learning PowerShell Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Building tools: The power of scripting

Building tools: The power of scripting - PowerShell Tutorial

From the course: Learning PowerShell Core

Start my 1-month free trial

Building tools: The power of scripting

- [Instructor] Now that you have a good indication of what you can pull out with CIM, let's start building a PowerShell script to do that. I've already started a PowerShell script here called Get-ServerInventory.ps1. It has two parameters: a Computer Name and Credential. That's going to allow us to pass any kind of remote computer name to this script. So let's first just go down through this. I'm not even going to run this script. I'm going to run each of these pieces individually. So, first off, let's just assign a computer name. For this, I do not have DNS set up so all we use that IP address of our remote Windows Server 2019 server. So now that I have the computer name variable, I can copy and paste this Server Info hash table here, and now we have that in memory. Now we can create a CIM session that's essentially like a PowerShell session, but it's for CIM and WMI calls. Now we do need a credential connected to this…

Contents