{"id":221,"date":"2015-03-26T21:29:21","date_gmt":"2015-03-26T20:29:21","guid":{"rendered":"http:\/\/christianlehrer.com\/?p=221"},"modified":"2015-03-26T21:31:24","modified_gmt":"2015-03-26T20:31:24","slug":"powershell-interactive-filter-with-out-gridview","status":"publish","type":"post","link":"https:\/\/christianlehrer.com\/?p=221","title":{"rendered":"PowerShell interactive filter with Out-GridView"},"content":{"rendered":"<div class=\"shariff\" data-title=\"PowerShell interactive filter with Out-GridView\" data-info-url=\"http:\/\/ct.de\/-2467514\" data-backend-url=\"https:\/\/christianlehrer.com\/wp-content\/plugins\/shariff-sharing\/backend\/index.php\" data-temp=\"\/tmp\" data-ttl=\"60\" data-service=\"tlxr\" data-services='[\"facebook\",\"twitter\",\"linkedin\",\"xing\",\"reddit\",\"whatsapp\",\"mail\",\"info\"]' data-image=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb.png\" data-url=\"https:\/\/christianlehrer.com\/?p=221\" data-lang=\"en\" data-theme=\"white\" data-orientation=\"horizontal\"><\/div><p>Recently, during the first meeting of our new <a href=\"http:\/\/powershell-ug.com\/?p=25\" target=\"_blank\">south-german PowerShell Usergroup<\/a>, Rolf Masuch showed us a nice feature which I didn\u00b4t know: Using Out-GridView as interactive filter.<\/p>\n<p>Here is how to do it:<\/p>\n<p>The magic parameter is \u2013PassThru !<\/p>\n<p>If you want the user to select, let\u00b4s say, some services to stop, you just can get the output of Out-GridView with the parameter PassThru:<\/p>\n<p>$result = Get-Service | Out-GridView \u2013PassThru<\/p>\n<p><a href=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image.png\"><img decoding=\"async\" loading=\"lazy\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb.png\" alt=\"image\" width=\"460\" height=\"34\" border=\"0\" \/><\/a><\/p>\n<p>will show you a grid of all your services:<\/p>\n<p><a href=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image1.png\"><img decoding=\"async\" loading=\"lazy\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb1.png\" alt=\"image\" width=\"596\" height=\"347\" border=\"0\" \/><\/a><\/p>\n<p>By filtering in the grid and pressing OK, you can select which services should land in $result:<\/p>\n<p><a href=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image2.png\"><img decoding=\"async\" loading=\"lazy\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb2.png\" alt=\"image\" width=\"368\" height=\"147\" border=\"0\" \/><\/a><\/p>\n<p>$result now only holds the services that were in the filter in your grid:<\/p>\n<p><a href=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image3.png\"><img decoding=\"async\" loading=\"lazy\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb3.png\" alt=\"image\" width=\"479\" height=\"99\" border=\"0\" \/><\/a><\/p>\n<p>Now you could use $result for stopping the user selected services<\/p>\n<p><a href=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image4.png\"><img decoding=\"async\" loading=\"lazy\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/christianlehrer.com\/wp-content\/uploads\/2015\/03\/image_thumb4.png\" alt=\"image\" width=\"376\" height=\"38\" border=\"0\" \/><\/a><\/p>\n<p>I think this is a nice little option if you have some interactive scripts.<\/p>\n<p>Have a nice day!<\/p>\n<p>Christian<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, during the first meeting of our new south-german PowerShell Usergroup, Rolf Masuch showed us a nice feature which I didn\u00b4t know: Using Out-GridView as interactive filter. Here is how to do it: The magic parameter is \u2013PassThru ! If you want the user to select, let\u00b4s say, some services to stop, you just can&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/posts\/221"}],"collection":[{"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=221"}],"version-history":[{"count":3,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=\/wp\/v2\/posts\/221\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/christianlehrer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/christianlehrer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}