Fun with PowerShell: System Information, part 1
November 25, 2008
posted by James Kehr
When it comes to system administration I have one very simple rule: all repetitive tasks should be scripted. Sure you may spend a day or two, or longer for those especially pesky tasks, hammering out a working script, but once that script is written you can use it indefinitely for years to come. And what better way is there to script in Windows than PowerShell? I dare you to say VBscript, I could use a good laugh today – I’ve had a nasty head cold for the past few days.
Speaking of being sick, why is it that you always get sick on, or just before, a weekend or holiday?
Back to the task at hand. To make a long story short, and those who know me can attest to my long-windedness, I needed to develop a script which would call our SQL server and grab a list of available servers, then remotely pull the server’s detailed hardware and operating system information through WMI, turn the WMI goobly-gook into pretty HTML, and lastly upload that information to the sales team’s SharePoint site. Piece of cake, right?
Did I mention the most I’ve programmed since I completed my Java programming class in 1998 were some simple batch files? I didn’t think so. This script is a testament to how easy it is to learn PowerShell, how strong the community is, and how flexible the language/shell is. PowerShell 2.0 is going to be even better, too. But I digress, let me show you the outcome of my system information script – slightly edited for security reasons.
Computer Name
XXXXX
Make and model
Dell Inc. PowerEdge M600
Dell Serial #: 1XXXXX1
Operating System
Microsoft® Windows Server® 2008 Standard 64-bit
RAM
Physical memory: 8 GiB
- DIMM1 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM2 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM3 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM4 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM5 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM6 = 1 GiB
- Model: HYMP512F72CP8N3-Y5
- DIMM7 = 1 GiB
- Model: HYMP512F72CP8D3-Y5
- DIMM8 = 1 GiB
- Model: NT1GT72U8PB1BN-3C
Total available memory slots: 8
Memory slots in use: 8
Unused memory slots: 0
CPU
No. of CPUs: 1
Intel(R) Xeon(R) CPU E5405 @ 2.00GHz
- No. of cores: 4
- Details: Intel64 Family 6 Model 23 Stepping 6
Total No. of logical CPU cores: 4
Disk information
Number of Virtual Disks: 2
Virtual disk 1 size: 72 GB
- Partition 1
- Drive C:
- Name: OS
- Size: 21.5 GB
- Free: 1.4 GB
- Partition 2
- Drive D:
- Name: Data
- Size: 50.5 GB
- Free: 16.9 GB
Physical disk(s):
ST973402SS
Google details
ST973402SS
Google details
Network Information
NICs
- Broadcom BCM5708S NetXtreme II GigE
- Broadcom BCM5708S NetXtreme II GigE
IP Addresses:
-
- xxx.xxx.xxx.xxx
- xxx.xxx.xxx.xxx
- ::1
v4
v6
I also made a stand-alone variant of this script for data center duties so I can get a quick peek at a system if a client requests an upgrade. This will be the variation on the system information script that I will ultimately be detailing in this series of blog posts. After that I’ll go into customizations that can easily be implemented by strategically adding a function here and there. Tune in next week and I’ll get into the juicy yumminess of the script.
#James Kehr
Get-Member $OW | ?{$_.title –eq “System Administrator”`
–and $_.certification –contains “MCSE 2000, MCDST, Network+, A+”}
New-Variable –name company –value ‘ORCS Web, Inc.’ –description ‘www.orcsweb.com’












