{"id":442,"date":"2013-05-29T11:43:54","date_gmt":"2013-05-29T01:43:54","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=442"},"modified":"2014-02-24T11:30:29","modified_gmt":"2014-02-24T00:30:29","slug":"how-to-use-multiple-filters-at-once-with-get-view","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=442","title":{"rendered":"How to use multiple filters at once with Get-View"},"content":{"rendered":"<p>Writing a Virtual Machine (VM) report the other day to gather a list of VMs that conform to a known naming standard.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n\r\n$vmlist = Get-View -ViewType VirtualMachine -Property Name -Filter @{&quot;Name&quot;=&quot;[a-z1-9]ap1&quot;} | Select Name\r\n\r\n<\/pre>\n<p>Then when I did a count to confirm I found that I had many VMs than I expected. Upon investigation I found that this actually returns all Templates as well. So then how do a filter the templates out. The following filter will do this.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n\r\n-Filter @{&quot;Config.Template&quot;=&quot;false&quot;}<\/pre>\n<p>How do I combine these? Using an -and inside and outside the filter block did not work.<\/p>\n<p>Semi colon is the answer. So my query becomes.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n\r\n$vmlist = Get-View -ViewType VirtualMachine -Property Name -Filter @{&quot;Name&quot;=&quot;[a-z1-9]ap1&quot;; &quot;Config.Template&quot;=&quot;false&quot;} | Select Name\r\n\r\n<\/pre>\n<p>The output of this command is an AND. Combing both of these filters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Writing a Virtual Machine (VM) report the other day to gather a list of VMs that conform to a known naming standard. Then when I did a count to confirm <a href=\"https:\/\/threemillion.net\/blog\/?p=442\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":""},"categories":[49],"tags":[56,55],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/442"}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=442"}],"version-history":[{"count":4,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":482,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions\/482"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}