We Don’t Need No Stinkin’ Scripts…
Another reason to love PowerShell… the command line. We work directly with objects in the command shell; minimal code required. The days of writing VBScripts to pull system information is long gone. Still hanging on to VBScript, resistant to change, this article may just change your mind…
At a minimum, it takes only two words to pull the default WMI properties of a class using PowerShell:
- Get-WmiObject cmdlet.
- The WMI Class you wish to enumerate.
For example:
How sick is that?!?
How about getting the default properties of the computer system class:
Let’s go a step further and list all the properties of the win32_ComputerSystem class using a regular expression:
Now let’s just get properties we are interested in. Choose any property you wish:
I know what you are thinking, this is great for gathering information from the local computer, how do we gather the same information from remote computers?
Introducing the greatest parameter of the all… (drum-roll please)……… -ComputerName!!!
Using the Format cmdlet let’s get all the properties from a remote Computer:
So the next time the boss inquires about how much drive space is available on a server, don’t write a VBScript, just run the PowerShell commands above. What a time saver!!! Of course, if the boss wants the same report from multiple remote servers, time to write a “PowerShell” script…
Email This Post To A Friend
« Organizing Script Code - Calling Scripts from Other Script Files | Home | “Let’s do the Time Zone Again…” »






Comments
Awesome! Now run that in WinPE for me.
Powershell is great, but it is limited by requiring a full running o/s to work. Even then, it won’t work on Windows 2008 Server Core …
Leave a Comment