4 Replies Latest reply on Dec 11, 2019 5:03 AM by LucD

    How do I filter the advanced properties list?

    StephenMoll Hot Shot

      The following line produces quite a long list of output:

      Get-VMHost -Name $VMHostName | Get-VMHostAdvancedConfiguration

       

      How do I filter the list so that I see only entries where the key contains a string?

       

      For example output all key/value pairs where the key starts "Config."?

       

      I feel I should know this, but messing around with Where-Object has got me no where.

        • 1. Re: How do I filter the advanced properties list?
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          With a mask on the Name parameter.

           

          Get-VMHost -Name $VMHostName |

          Get-VMHostAdvancedConfiguration -Name "config*"

           

          Or even better, with Get-AdvancedSetting

           

          Get-VMHost -Name $VMHostName |

          Get-AdvancedSetting -Name "config*"

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: How do I filter the advanced properties list?
            StephenMoll Hot Shot

            Can I wildcard the search term?

            • 3. Re: How do I filter the advanced properties list?
              StephenMoll Hot Shot

              Yes I can!

               

              Thanks...

               

              Get-Host -Name $VMHostName | Get-AdvancedSetting -Name "Config.*"

               

               

              Name                 Value                Type                 Description                  

              ----                 -----                ----                 -----------                  

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.HostAgent....                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.HostAgent.... True                 VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.HostAgent.... 100                  VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.HostAgent....                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.Defaults.c...                      VMHost                                            

              Config.Defaults.c... disable              VMHost                                            

              Config.HostAgent....                      VMHost                                            

              Config.Defaults.c... disable              VMHost                       

              • 4. Re: How do I filter the advanced properties list?
                LucD Guru
                Community WarriorsvExpertUser Moderators

                A possible issue could be that the available meta-characters for masking the name are limited.
                An asterisk (*) for one or more characters, a question mark (?) for 1 character.

                 

                For more advanced filtering you will probably need to use a Where-Object and the -match operator with a RegEx expression.

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz