Wednesday, January 08, 2014

Useful ps filters

To filter results from a powershell query where-object can be used.

For example to filter get-spserviceapplication by field typename

/>Get-spserviceapplication |where-object{$_.typename –like “Search Service”

will result in all objects that contains Search Service. Switch –like for –eq to more precise results.

To get specific field to a variable

/>$serviceid = Get-spserviceapplication |where-object{$_.typename –like “Search Service”  |select id

Simple but powerful.


No comments: