To demonstrate this the code example below will
- Query the application event log of a remote server
- Order the log entries by the date they occurred
- Return the first 5 results from the set
The cmdlet Get-WmiObject is the gateway to WMI and allowed me to complete the first step with this simple command
As the results from the WMI query are stored in an array, I’m now free to manipulate the result set further using the commands available in PowerShell. Completing items two and three on my list only requires this command
The big win here is being able to run a query on a remote server but manipulate the result set on my local machine. WMI has a large set of providers which are now only a query away from my console.