Collecting System Information with PowerShell

At the Detroit SQL Saturday last week I was going to attempt something new. I had handed index cards and asked everyone to write an example of what they would like to see PowerShell do.  Bellow is an example of one of the index cards that I had collected.  The the idea was good in theory.  However, I will be pulling it from my next presentation.

Show Mapped Drives

image

In this example I have use the Win32_LogicalDisk WMI class to retrieve the DeviceID and Provider Name.  The DeviceID is the Drive Letter that is being mapped and the Provider name displays the Network Path.  We filter on DriveType 4 which is the network drive.

Show Drive Size and Free Space

image

In this example, we again use the Win32_LogicalDrive WMI class.  However, this time we filter on DriveType 3 which is logical drives.  In addition, this time we retrieve the properties of size and freespace also.

Show Total Memory and Memory Used

image

This time we use the Win32_OperatingSystem WMI class and retrieve TotalVisibleMemory and FreePhysicalMemory.

Show CPU Utilization

image

For our final example we are going to use the Get-Counter cmdlet to retrieve the performance counter for Processor Time.  We collect 5 samples at a second between and then return the average of the 5 counts.

The scripts can be found here.

Happy scripting.

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s