|
|
 
3 |
I'm not a full fledged powershell person as of "yet". In the few things that I have done, however, I have seen a trend that can hurt more than help in some cases.
The traditional PowerShell example is:
|
Get-Somthing | where {$_.name -eq 'this or that'}
|
When you have 10 or 20 simple objects, that is fine. The down side is when you are pulling data from a remote location like the SDK. Basically you are saying GET everything and bring it to my computer so I can sort through it further.
Let's say the "Get-Something" returns 50,000 objects of type "something" (maybe closed alerts in the console) and you only want 3 of those objects because only 3 of them have a property with a specific value "Type='Very Special'"
Let's try it this way now...
|
Get-Somthing -Criteria "Type ='Very Special'"
|
What you said here is, look through the 50,000 objects of type "something" and only send me the objects where the Type is equal to "Very Special". Now you only get the 3 objects with that value. Granted there could be more or less, the point of the example is that you want to pull the least amount of data from a remote source possible. the less you pull down, the less you process locally and the less time you wait for the data to come down to you. This improves performance significantly.
Of course you could further filter on the client side by piping to WHERE.
One cmdLet in Operations Manager that has the Criteria Option is GET-Task. If you have 1000 tasks and you want to get all that are your custom tasks that you name with "MT-" at the beginning of the Task Name, you could use the following:
|
Get-Task -Criteria "Name like 'MT-%'"
|
Now instead of downloading all 1000, you only pulled down YOUR tasks. You can then further process them.
Personally, I feel cmdlet's should always include a criteria option where data is remotely transferred and can be filtered at the source.
If you like boosting performance like this, please take the time to comment to microsoft that you would like to see more server-side criteria options in powershell. the connect site is a good start. https://connect.microsoft.com
if you are on the TAP for Operations Manager and have access, please read my comments to MS regarding the use of criteria and Increase the vote count if you agree with me.
https://connect.microsoft.com/site799/feedback/details/585599/criteria-option-in-cmdlet-powershell