Collecting System Information with PowerShell
Posted: March 23, 2013 Filed under: PowerShell, Script, SQLSaturday Leave a commentAt 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
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
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
This time we use the Win32_OperatingSystem WMI class and retrieve TotalVisibleMemory and FreePhysicalMemory.
Show CPU Utilization
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.