Select-Object with Out-GridView










0















I am creating a tool for our help desk to copy frequent resolution comments they may use when resolving tickets. I currently have:



Get-ChildItem ".FileStore" | Out-GridView -PassThru -Title "Quick Notes" | Get-Content | Set-Clipboard


Which outputs something similar to (but in GridView):



Mode LastWriteTime Length Name 
---- ------------- ------ ----
-a---- 15/11/2018 14:38 14 1.txt
-a---- 15/11/2018 14:39 14 2.txt
-a---- 15/11/2018 14:39 14 3.txt
-a---- 15/11/2018 14:39 14 4.txt


I am aiming to just have the Name column output, however I am unsure on how to achieve this. I have tried Select, Select-Object and Format-Table which do not work, as I receive the following:



Get-Content : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of 
the parameters that take pipeline input.


Is it possible to output only the Name column to the GridView?










share|improve this question




























    0















    I am creating a tool for our help desk to copy frequent resolution comments they may use when resolving tickets. I currently have:



    Get-ChildItem ".FileStore" | Out-GridView -PassThru -Title "Quick Notes" | Get-Content | Set-Clipboard


    Which outputs something similar to (but in GridView):



    Mode LastWriteTime Length Name 
    ---- ------------- ------ ----
    -a---- 15/11/2018 14:38 14 1.txt
    -a---- 15/11/2018 14:39 14 2.txt
    -a---- 15/11/2018 14:39 14 3.txt
    -a---- 15/11/2018 14:39 14 4.txt


    I am aiming to just have the Name column output, however I am unsure on how to achieve this. I have tried Select, Select-Object and Format-Table which do not work, as I receive the following:



    Get-Content : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of 
    the parameters that take pipeline input.


    Is it possible to output only the Name column to the GridView?










    share|improve this question


























      0












      0








      0


      0






      I am creating a tool for our help desk to copy frequent resolution comments they may use when resolving tickets. I currently have:



      Get-ChildItem ".FileStore" | Out-GridView -PassThru -Title "Quick Notes" | Get-Content | Set-Clipboard


      Which outputs something similar to (but in GridView):



      Mode LastWriteTime Length Name 
      ---- ------------- ------ ----
      -a---- 15/11/2018 14:38 14 1.txt
      -a---- 15/11/2018 14:39 14 2.txt
      -a---- 15/11/2018 14:39 14 3.txt
      -a---- 15/11/2018 14:39 14 4.txt


      I am aiming to just have the Name column output, however I am unsure on how to achieve this. I have tried Select, Select-Object and Format-Table which do not work, as I receive the following:



      Get-Content : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of 
      the parameters that take pipeline input.


      Is it possible to output only the Name column to the GridView?










      share|improve this question
















      I am creating a tool for our help desk to copy frequent resolution comments they may use when resolving tickets. I currently have:



      Get-ChildItem ".FileStore" | Out-GridView -PassThru -Title "Quick Notes" | Get-Content | Set-Clipboard


      Which outputs something similar to (but in GridView):



      Mode LastWriteTime Length Name 
      ---- ------------- ------ ----
      -a---- 15/11/2018 14:38 14 1.txt
      -a---- 15/11/2018 14:39 14 2.txt
      -a---- 15/11/2018 14:39 14 3.txt
      -a---- 15/11/2018 14:39 14 4.txt


      I am aiming to just have the Name column output, however I am unsure on how to achieve this. I have tried Select, Select-Object and Format-Table which do not work, as I receive the following:



      Get-Content : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of 
      the parameters that take pipeline input.


      Is it possible to output only the Name column to the GridView?







      powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 16:15







      ryanmaddock

















      asked Nov 15 '18 at 16:10









      ryanmaddockryanmaddock

      74110




      74110






















          2 Answers
          2






          active

          oldest

          votes


















          1














          To allow Get-Content to find the file, you need to select more than just a Name, because Get-Content have no way to interpret the Name property. It have no matching parameter. Best thing to select is PSPath property, which contains fully qualified PowerShell path? and will match LiteralPath parameter of Get-Content cmdlet.



          Sadly Out-GridView does not have direct way to specify which properties to display, but it use standard PowerShell mechanism for selecting them. So, we can use it instead. To do that you need to attach MemberSet property PSStandardMembers with property set DefaultDisplayPropertySet, which says which properties to display by default.



          Get-ChildItem ".FileStore" |
          Select-Object Name, PSPath |
          Add-Member -MemberType MemberSet `
          -Name PSStandardMembers `
          -Value ([System.Management.Automation.PSPropertySet]::new(
          'DefaultDisplayPropertySet',
          [string]('Name')
          )) `
          -PassThru |
          Out-GridView -PassThru -Title "Quick Notes" |
          Get-Content | Set-Clipboard





          share|improve this answer






























            0














            That looks very like my answer to a deleted question from user Adam partly surfacing in a follow-up question



            My answer (with a different path) was this:



            Get-ChildItem -Path ".FileStore" |
            Select-Object Name,FullName |
            Out-GridView -PassThru -Title "Quick Notes"|
            ForEach-Object Set-Clipboard -Append





            share|improve this answer






















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323526%2fselect-object-with-out-gridview%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              To allow Get-Content to find the file, you need to select more than just a Name, because Get-Content have no way to interpret the Name property. It have no matching parameter. Best thing to select is PSPath property, which contains fully qualified PowerShell path? and will match LiteralPath parameter of Get-Content cmdlet.



              Sadly Out-GridView does not have direct way to specify which properties to display, but it use standard PowerShell mechanism for selecting them. So, we can use it instead. To do that you need to attach MemberSet property PSStandardMembers with property set DefaultDisplayPropertySet, which says which properties to display by default.



              Get-ChildItem ".FileStore" |
              Select-Object Name, PSPath |
              Add-Member -MemberType MemberSet `
              -Name PSStandardMembers `
              -Value ([System.Management.Automation.PSPropertySet]::new(
              'DefaultDisplayPropertySet',
              [string]('Name')
              )) `
              -PassThru |
              Out-GridView -PassThru -Title "Quick Notes" |
              Get-Content | Set-Clipboard





              share|improve this answer



























                1














                To allow Get-Content to find the file, you need to select more than just a Name, because Get-Content have no way to interpret the Name property. It have no matching parameter. Best thing to select is PSPath property, which contains fully qualified PowerShell path? and will match LiteralPath parameter of Get-Content cmdlet.



                Sadly Out-GridView does not have direct way to specify which properties to display, but it use standard PowerShell mechanism for selecting them. So, we can use it instead. To do that you need to attach MemberSet property PSStandardMembers with property set DefaultDisplayPropertySet, which says which properties to display by default.



                Get-ChildItem ".FileStore" |
                Select-Object Name, PSPath |
                Add-Member -MemberType MemberSet `
                -Name PSStandardMembers `
                -Value ([System.Management.Automation.PSPropertySet]::new(
                'DefaultDisplayPropertySet',
                [string]('Name')
                )) `
                -PassThru |
                Out-GridView -PassThru -Title "Quick Notes" |
                Get-Content | Set-Clipboard





                share|improve this answer

























                  1












                  1








                  1







                  To allow Get-Content to find the file, you need to select more than just a Name, because Get-Content have no way to interpret the Name property. It have no matching parameter. Best thing to select is PSPath property, which contains fully qualified PowerShell path? and will match LiteralPath parameter of Get-Content cmdlet.



                  Sadly Out-GridView does not have direct way to specify which properties to display, but it use standard PowerShell mechanism for selecting them. So, we can use it instead. To do that you need to attach MemberSet property PSStandardMembers with property set DefaultDisplayPropertySet, which says which properties to display by default.



                  Get-ChildItem ".FileStore" |
                  Select-Object Name, PSPath |
                  Add-Member -MemberType MemberSet `
                  -Name PSStandardMembers `
                  -Value ([System.Management.Automation.PSPropertySet]::new(
                  'DefaultDisplayPropertySet',
                  [string]('Name')
                  )) `
                  -PassThru |
                  Out-GridView -PassThru -Title "Quick Notes" |
                  Get-Content | Set-Clipboard





                  share|improve this answer













                  To allow Get-Content to find the file, you need to select more than just a Name, because Get-Content have no way to interpret the Name property. It have no matching parameter. Best thing to select is PSPath property, which contains fully qualified PowerShell path? and will match LiteralPath parameter of Get-Content cmdlet.



                  Sadly Out-GridView does not have direct way to specify which properties to display, but it use standard PowerShell mechanism for selecting them. So, we can use it instead. To do that you need to attach MemberSet property PSStandardMembers with property set DefaultDisplayPropertySet, which says which properties to display by default.



                  Get-ChildItem ".FileStore" |
                  Select-Object Name, PSPath |
                  Add-Member -MemberType MemberSet `
                  -Name PSStandardMembers `
                  -Value ([System.Management.Automation.PSPropertySet]::new(
                  'DefaultDisplayPropertySet',
                  [string]('Name')
                  )) `
                  -PassThru |
                  Out-GridView -PassThru -Title "Quick Notes" |
                  Get-Content | Set-Clipboard






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 19:14









                  PetSerAlPetSerAl

                  15.8k12950




                  15.8k12950























                      0














                      That looks very like my answer to a deleted question from user Adam partly surfacing in a follow-up question



                      My answer (with a different path) was this:



                      Get-ChildItem -Path ".FileStore" |
                      Select-Object Name,FullName |
                      Out-GridView -PassThru -Title "Quick Notes"|
                      ForEach-Object Set-Clipboard -Append





                      share|improve this answer



























                        0














                        That looks very like my answer to a deleted question from user Adam partly surfacing in a follow-up question



                        My answer (with a different path) was this:



                        Get-ChildItem -Path ".FileStore" |
                        Select-Object Name,FullName |
                        Out-GridView -PassThru -Title "Quick Notes"|
                        ForEach-Object Set-Clipboard -Append





                        share|improve this answer

























                          0












                          0








                          0







                          That looks very like my answer to a deleted question from user Adam partly surfacing in a follow-up question



                          My answer (with a different path) was this:



                          Get-ChildItem -Path ".FileStore" |
                          Select-Object Name,FullName |
                          Out-GridView -PassThru -Title "Quick Notes"|
                          ForEach-Object Set-Clipboard -Append





                          share|improve this answer













                          That looks very like my answer to a deleted question from user Adam partly surfacing in a follow-up question



                          My answer (with a different path) was this:



                          Get-ChildItem -Path ".FileStore" |
                          Select-Object Name,FullName |
                          Out-GridView -PassThru -Title "Quick Notes"|
                          ForEach-Object Set-Clipboard -Append






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 15 '18 at 19:06









                          LotPingsLotPings

                          19.8k61633




                          19.8k61633



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323526%2fselect-object-with-out-gridview%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              這個網誌中的熱門文章

                              Barbados

                              How to read a connectionString WITH PROVIDER in .NET Core?

                              Node.js Script on GitHub Pages or Amazon S3