I was poking around WMI the other day in PowerShell and was intrigued by the Win32_Share class. This is a great way to find out what items are shared on a server such as printers and folders, although it’s not limited to those types of resources. I thought this would make a useful function; one…
Tag: WMI
Find Non System Service Accounts with PowerShell and WMI
As easy as Get-Service is to use in PowerShell, it has one limitation for IT Pros: it can’t show you what account the service is running under. In old school terms, “What is the service account?” Fortunately you can get that information using WMI. Here’s a query you can use that takes advantage of some…
Get Properties with Values
One of my nuisance issues when using WMI with Windows PowerShell, is that when looking at all properties I have to wade though many that have no value. I’d prefer to only view properties that have a populated value. Here’s one way.
Get Local Administrators with WMI and PowerShell
Earlier this week I was helping someone out on a problem working with the local administrators group. There are a variety of ways to enumerate the members of a local group. The code he was using involved WMI. I hadn’t really worked with the WMI approach in any great detail so I thought I’d see…
Get WMI Namespace
PowerShell and WMI just seem to go together like peanut butter and jelly, beer and pretzels, or salt and pepper. However, discovering things about WMI isn’t always so easy. There are plenty of tools and scripts that will help you uncover WMI goodness, but here’s another one anyway. Today’s PowerShell function will get all namespaces…
TechEd Atlanta – Managing the Registry with PowerShell
My second TechEd talk was about managing the registry with Windows PowerShell. If you were in the session you know that I stressed heavily using the PowerShell provider and cmdlets. For remote computers, leverage PowerShell’s remoting infrastructure. But I also discussed using the “raw” .NET classes as well as WMI (if you are really desperate…
Get Registry Size and Age
I’m not sure why the registry has been on my mind lately. I probably need a vacation to get out more. But I put together a relatively simple Windows PowerShell function to retrieve registry statistics that you might find useful. My Get-Registry function will return information about the size of a registry as well as…
Scripting Games 2011 Beginner Event 5 Commentary
My commentary for Beginner Event 5 in the 2011 Scripting Games is now available. One item that seems to be missing on the ScriptingGuys site is my complete solution so I thought I would share it here, plus a variation.
Get IP Data
I was doodling in PowerShell this morning and ended up with what I hope is a useful function to retrieve IP configuration information, sort of like IPCONFIG, but using WMI. The beauty is that I can connect to remote machines and the output is an object which leads to all sorts of possibilities. My function…
New Event Report Revised
Last year I posted an update to an old Mr. Roboto script that was an update to an even older VBScript. Still with me? My last revision leveraged the new Get-WinEvent cmdlet to create an HTML report of recent error activity on one or more computers. The problem was that I didn’t account for older…
More WMI Dates – Win32Product InstallDate
I’ve written in the past about converting obtuse WMI datetime formats into more user friendly formats. The other day via Twitter I got a question about the InstallDate property that comes from the Win32_Product class. This property has a different format, than what I’ve written about previously. And while I think the format is easy…
Friday Fun – The Kitchen Sink Prompt
On my last Friday Fun post on PowerShell prompts, I got a terrific comment from Bart Vandyck about his prompt which has just about everything you would want. I too have a “kitchen sink” prompt, that is to say, one with the proverbial “everything but the kitchen sink”. Or you might consider this an extreme…
Friday the 13 Script Blocks
In celebration of Friday the 13th and to help ward off any triskaidekaphobia I thought I’d offer up 13 PowerShell scriptblocks. These are scriptblocks that might solve a legitimate business need like finding how long a server has been running to the more mercurial such as how many hours before I can go home. A…
Get Parent Process
Recently I helping out on a post in the forums at ScriptingAnswers.com. The question centered around identifying processes on a computer and their parent process. There are many ways you could slice and dice this problem using WMI and Get-WmiObject. Getting the parent process ID is pretty simple, but going backwards from there to identify…
New WMI Object
I have one more variation on my recent theme of working with WMI objects. I wanted to come up with something flexible and re-usable where you could specify a WMI class and some properties and get a custom object with all the classes combined. My solution is a function called New-WmiObject. Function New-WMIObject { [cmdletbinding()]…