Get-ChildItem and wildcards and filtering












2















I have two different ways of getting files with a wildcard pattern:



Get-ChildItem "$ActivityLogDirectory/*.csv"


and



Get-ChildItem "$ActivityLogDirectory" -Filter *.csv


I prefer to use the latter instead of the former because the former (Get-ChildItem "$ActivityLogDirectory/*.csv") has, on occasion, given me a permission denied error.



They both appear to return the same results, but when I try to compress the resulting files with this command:



Compress-Archive -Update -Path $CsvFiles -DestinationPath C:UsersadminDownloadsfoo.zip


the former succeeds while the latter fails with the following error:




Compress-Archive : The path 'rgb dev automation store a_1-1_2194_20181120.csv'
either does not exist or is not a valid file system path.
At line:1 char:1
+ Compress-Archive -Update -Path $CsvFiles -DestinationPath C:Usersad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (rgb dev automat...94_20181120.csv:String) [Compress-Archive], InvalidOperationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive


So what's the difference between these two ways of getting a listing of files using wildcards? Or perhaps asked another way, why does using -Filter *.csv cause the Compress-Archive cmdlet to fail?



enter image description here










share|improve this question

























  • there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

    – Lee_Dailey
    Nov 28 '18 at 23:17











  • @Lee_Dailey yes, i have tried LiteralPath and the results are the same

    – HairOfTheDog
    Nov 28 '18 at 23:31











  • well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

    – Lee_Dailey
    Nov 28 '18 at 23:35











  • @Lee_Dailey I've tried that too and nothing changes

    – HairOfTheDog
    Nov 28 '18 at 23:42











  • ouch! i am out of ideas ... i'll go back to lurking. good luck!

    – Lee_Dailey
    Nov 29 '18 at 0:16
















2















I have two different ways of getting files with a wildcard pattern:



Get-ChildItem "$ActivityLogDirectory/*.csv"


and



Get-ChildItem "$ActivityLogDirectory" -Filter *.csv


I prefer to use the latter instead of the former because the former (Get-ChildItem "$ActivityLogDirectory/*.csv") has, on occasion, given me a permission denied error.



They both appear to return the same results, but when I try to compress the resulting files with this command:



Compress-Archive -Update -Path $CsvFiles -DestinationPath C:UsersadminDownloadsfoo.zip


the former succeeds while the latter fails with the following error:




Compress-Archive : The path 'rgb dev automation store a_1-1_2194_20181120.csv'
either does not exist or is not a valid file system path.
At line:1 char:1
+ Compress-Archive -Update -Path $CsvFiles -DestinationPath C:Usersad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (rgb dev automat...94_20181120.csv:String) [Compress-Archive], InvalidOperationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive


So what's the difference between these two ways of getting a listing of files using wildcards? Or perhaps asked another way, why does using -Filter *.csv cause the Compress-Archive cmdlet to fail?



enter image description here










share|improve this question

























  • there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

    – Lee_Dailey
    Nov 28 '18 at 23:17











  • @Lee_Dailey yes, i have tried LiteralPath and the results are the same

    – HairOfTheDog
    Nov 28 '18 at 23:31











  • well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

    – Lee_Dailey
    Nov 28 '18 at 23:35











  • @Lee_Dailey I've tried that too and nothing changes

    – HairOfTheDog
    Nov 28 '18 at 23:42











  • ouch! i am out of ideas ... i'll go back to lurking. good luck!

    – Lee_Dailey
    Nov 29 '18 at 0:16














2












2








2








I have two different ways of getting files with a wildcard pattern:



Get-ChildItem "$ActivityLogDirectory/*.csv"


and



Get-ChildItem "$ActivityLogDirectory" -Filter *.csv


I prefer to use the latter instead of the former because the former (Get-ChildItem "$ActivityLogDirectory/*.csv") has, on occasion, given me a permission denied error.



They both appear to return the same results, but when I try to compress the resulting files with this command:



Compress-Archive -Update -Path $CsvFiles -DestinationPath C:UsersadminDownloadsfoo.zip


the former succeeds while the latter fails with the following error:




Compress-Archive : The path 'rgb dev automation store a_1-1_2194_20181120.csv'
either does not exist or is not a valid file system path.
At line:1 char:1
+ Compress-Archive -Update -Path $CsvFiles -DestinationPath C:Usersad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (rgb dev automat...94_20181120.csv:String) [Compress-Archive], InvalidOperationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive


So what's the difference between these two ways of getting a listing of files using wildcards? Or perhaps asked another way, why does using -Filter *.csv cause the Compress-Archive cmdlet to fail?



enter image description here










share|improve this question
















I have two different ways of getting files with a wildcard pattern:



Get-ChildItem "$ActivityLogDirectory/*.csv"


and



Get-ChildItem "$ActivityLogDirectory" -Filter *.csv


I prefer to use the latter instead of the former because the former (Get-ChildItem "$ActivityLogDirectory/*.csv") has, on occasion, given me a permission denied error.



They both appear to return the same results, but when I try to compress the resulting files with this command:



Compress-Archive -Update -Path $CsvFiles -DestinationPath C:UsersadminDownloadsfoo.zip


the former succeeds while the latter fails with the following error:




Compress-Archive : The path 'rgb dev automation store a_1-1_2194_20181120.csv'
either does not exist or is not a valid file system path.
At line:1 char:1
+ Compress-Archive -Update -Path $CsvFiles -DestinationPath C:Usersad ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (rgb dev automat...94_20181120.csv:String) [Compress-Archive], InvalidOperationException
+ FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Compress-Archive


So what's the difference between these two ways of getting a listing of files using wildcards? Or perhaps asked another way, why does using -Filter *.csv cause the Compress-Archive cmdlet to fail?



enter image description here







powershell powershell-v5.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 28 '18 at 23:08









Ansgar Wiechers

146k13132191




146k13132191










asked Nov 28 '18 at 22:59









HairOfTheDogHairOfTheDog

1,06311525




1,06311525













  • there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

    – Lee_Dailey
    Nov 28 '18 at 23:17











  • @Lee_Dailey yes, i have tried LiteralPath and the results are the same

    – HairOfTheDog
    Nov 28 '18 at 23:31











  • well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

    – Lee_Dailey
    Nov 28 '18 at 23:35











  • @Lee_Dailey I've tried that too and nothing changes

    – HairOfTheDog
    Nov 28 '18 at 23:42











  • ouch! i am out of ideas ... i'll go back to lurking. good luck!

    – Lee_Dailey
    Nov 29 '18 at 0:16



















  • there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

    – Lee_Dailey
    Nov 28 '18 at 23:17











  • @Lee_Dailey yes, i have tried LiteralPath and the results are the same

    – HairOfTheDog
    Nov 28 '18 at 23:31











  • well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

    – Lee_Dailey
    Nov 28 '18 at 23:35











  • @Lee_Dailey I've tried that too and nothing changes

    – HairOfTheDog
    Nov 28 '18 at 23:42











  • ouch! i am out of ideas ... i'll go back to lurking. good luck!

    – Lee_Dailey
    Nov 29 '18 at 0:16

















there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

– Lee_Dailey
Nov 28 '18 at 23:17





there may be an odd character in the file name that is giving you that error. have you tried -LiteralPath instead of -Path?

– Lee_Dailey
Nov 28 '18 at 23:17













@Lee_Dailey yes, i have tried LiteralPath and the results are the same

– HairOfTheDog
Nov 28 '18 at 23:31





@Lee_Dailey yes, i have tried LiteralPath and the results are the same

– HairOfTheDog
Nov 28 '18 at 23:31













well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

– Lee_Dailey
Nov 28 '18 at 23:35





well, that is one easy fix that aint a fix. [sigh ...] ///// what happens if you leave off the entirely unneeded quotes in this line Get-ChildItem "$ActivityLogDirectory" -Filter *.csv?

– Lee_Dailey
Nov 28 '18 at 23:35













@Lee_Dailey I've tried that too and nothing changes

– HairOfTheDog
Nov 28 '18 at 23:42





@Lee_Dailey I've tried that too and nothing changes

– HairOfTheDog
Nov 28 '18 at 23:42













ouch! i am out of ideas ... i'll go back to lurking. good luck!

– Lee_Dailey
Nov 29 '18 at 0:16





ouch! i am out of ideas ... i'll go back to lurking. good luck!

– Lee_Dailey
Nov 29 '18 at 0:16












2 Answers
2






active

oldest

votes


















2














The reason you're seeing different behavior is the - obscurely situational - stringification behavior of the objects output by Get-ChildItem:



This answer details when Get-ChildItem output happens to stringify to a mere filename vs. a full path, and it so happens that Get-ChildItem "$ActivityLogDirectory" -Filter *.csv stringifies to mere filenames.



The workaround is to explicitly stringify the objects as their full paths via their FullName property (PSv3+ syntax):



$CsvFiles = (Get-ChildItem "$ActivityLogDirectory" -Filter *.csv).FullName





share|improve this answer































    1














    If you are running this from a shell with the location of the folder where the CSV files are located then this will work. What you are doing by passing the $CsvFiles variable into Compress-Archive is trying to run against the file name in the current context. To fix this pass the full path $CsvFiles.FullName:



    $Csvfiles = (Get-Childitem $ActivityLogDirectory -Filter *.csv)
    Compress-Archive -Update -Path $Csvfiles.fullname -DestinationPath C:UsersadminDownloadsfoo.zip





    share|improve this answer
























    • Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

      – HairOfTheDog
      Nov 28 '18 at 23:48











    • I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

      – Owain Esau
      Nov 28 '18 at 23:58











    • Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

      – HairOfTheDog
      Nov 29 '18 at 0:02






    • 1





      Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

      – Owain Esau
      Nov 29 '18 at 0:07














    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%2f53529385%2fget-childitem-and-wildcards-and-filtering%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









    2














    The reason you're seeing different behavior is the - obscurely situational - stringification behavior of the objects output by Get-ChildItem:



    This answer details when Get-ChildItem output happens to stringify to a mere filename vs. a full path, and it so happens that Get-ChildItem "$ActivityLogDirectory" -Filter *.csv stringifies to mere filenames.



    The workaround is to explicitly stringify the objects as their full paths via their FullName property (PSv3+ syntax):



    $CsvFiles = (Get-ChildItem "$ActivityLogDirectory" -Filter *.csv).FullName





    share|improve this answer




























      2














      The reason you're seeing different behavior is the - obscurely situational - stringification behavior of the objects output by Get-ChildItem:



      This answer details when Get-ChildItem output happens to stringify to a mere filename vs. a full path, and it so happens that Get-ChildItem "$ActivityLogDirectory" -Filter *.csv stringifies to mere filenames.



      The workaround is to explicitly stringify the objects as their full paths via their FullName property (PSv3+ syntax):



      $CsvFiles = (Get-ChildItem "$ActivityLogDirectory" -Filter *.csv).FullName





      share|improve this answer


























        2












        2








        2







        The reason you're seeing different behavior is the - obscurely situational - stringification behavior of the objects output by Get-ChildItem:



        This answer details when Get-ChildItem output happens to stringify to a mere filename vs. a full path, and it so happens that Get-ChildItem "$ActivityLogDirectory" -Filter *.csv stringifies to mere filenames.



        The workaround is to explicitly stringify the objects as their full paths via their FullName property (PSv3+ syntax):



        $CsvFiles = (Get-ChildItem "$ActivityLogDirectory" -Filter *.csv).FullName





        share|improve this answer













        The reason you're seeing different behavior is the - obscurely situational - stringification behavior of the objects output by Get-ChildItem:



        This answer details when Get-ChildItem output happens to stringify to a mere filename vs. a full path, and it so happens that Get-ChildItem "$ActivityLogDirectory" -Filter *.csv stringifies to mere filenames.



        The workaround is to explicitly stringify the objects as their full paths via their FullName property (PSv3+ syntax):



        $CsvFiles = (Get-ChildItem "$ActivityLogDirectory" -Filter *.csv).FullName






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 29 '18 at 2:13









        mklement0mklement0

        138k22255293




        138k22255293

























            1














            If you are running this from a shell with the location of the folder where the CSV files are located then this will work. What you are doing by passing the $CsvFiles variable into Compress-Archive is trying to run against the file name in the current context. To fix this pass the full path $CsvFiles.FullName:



            $Csvfiles = (Get-Childitem $ActivityLogDirectory -Filter *.csv)
            Compress-Archive -Update -Path $Csvfiles.fullname -DestinationPath C:UsersadminDownloadsfoo.zip





            share|improve this answer
























            • Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

              – HairOfTheDog
              Nov 28 '18 at 23:48











            • I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

              – Owain Esau
              Nov 28 '18 at 23:58











            • Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

              – HairOfTheDog
              Nov 29 '18 at 0:02






            • 1





              Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

              – Owain Esau
              Nov 29 '18 at 0:07


















            1














            If you are running this from a shell with the location of the folder where the CSV files are located then this will work. What you are doing by passing the $CsvFiles variable into Compress-Archive is trying to run against the file name in the current context. To fix this pass the full path $CsvFiles.FullName:



            $Csvfiles = (Get-Childitem $ActivityLogDirectory -Filter *.csv)
            Compress-Archive -Update -Path $Csvfiles.fullname -DestinationPath C:UsersadminDownloadsfoo.zip





            share|improve this answer
























            • Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

              – HairOfTheDog
              Nov 28 '18 at 23:48











            • I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

              – Owain Esau
              Nov 28 '18 at 23:58











            • Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

              – HairOfTheDog
              Nov 29 '18 at 0:02






            • 1





              Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

              – Owain Esau
              Nov 29 '18 at 0:07
















            1












            1








            1







            If you are running this from a shell with the location of the folder where the CSV files are located then this will work. What you are doing by passing the $CsvFiles variable into Compress-Archive is trying to run against the file name in the current context. To fix this pass the full path $CsvFiles.FullName:



            $Csvfiles = (Get-Childitem $ActivityLogDirectory -Filter *.csv)
            Compress-Archive -Update -Path $Csvfiles.fullname -DestinationPath C:UsersadminDownloadsfoo.zip





            share|improve this answer













            If you are running this from a shell with the location of the folder where the CSV files are located then this will work. What you are doing by passing the $CsvFiles variable into Compress-Archive is trying to run against the file name in the current context. To fix this pass the full path $CsvFiles.FullName:



            $Csvfiles = (Get-Childitem $ActivityLogDirectory -Filter *.csv)
            Compress-Archive -Update -Path $Csvfiles.fullname -DestinationPath C:UsersadminDownloadsfoo.zip






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 28 '18 at 23:44









            Owain EsauOwain Esau

            944920




            944920













            • Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

              – HairOfTheDog
              Nov 28 '18 at 23:48











            • I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

              – Owain Esau
              Nov 28 '18 at 23:58











            • Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

              – HairOfTheDog
              Nov 29 '18 at 0:02






            • 1





              Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

              – Owain Esau
              Nov 29 '18 at 0:07





















            • Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

              – HairOfTheDog
              Nov 28 '18 at 23:48











            • I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

              – Owain Esau
              Nov 28 '18 at 23:58











            • Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

              – HairOfTheDog
              Nov 29 '18 at 0:02






            • 1





              Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

              – Owain Esau
              Nov 29 '18 at 0:07



















            Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

            – HairOfTheDog
            Nov 28 '18 at 23:48





            Your answer gets Compress-Archive to work, but I'd still like to know what the difference is between the two ways of using Get-ChildItem with wildcards

            – HairOfTheDog
            Nov 28 '18 at 23:48













            I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

            – Owain Esau
            Nov 28 '18 at 23:58





            I am not entirely sure both methods work for me. Can you see what the results are for $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames where $CsvFiles is populated using Get-ChildItem "$ActivityLogDirectory" -Filter *.csv ?

            – Owain Esau
            Nov 28 '18 at 23:58













            Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

            – HairOfTheDog
            Nov 29 '18 at 0:02





            Using either way of calling Get-ChildItem and then calling $CsvFiles.psstandardmembers.DefaultDisplayPropertySet.ReferencedPropertyNames returns the same results LastWriteTime, Length and Name

            – HairOfTheDog
            Nov 29 '18 at 0:02




            1




            1





            Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

            – Owain Esau
            Nov 29 '18 at 0:07







            Strange, i am getting the same results now: What if: Performing the operation "Compress-Archive" on target " C:testNew Microsoft Excel Workshee.csv C:testNew Microsoft Excel Worksheet (2).csv". When you create the variable with your first method, the full path is being passed to Compress-Archive with the second, it is only passing the name Compress-Archive : The path 'New Microsoft Excel Workshee.csv' either does not exist or is not a valid file system path

            – Owain Esau
            Nov 29 '18 at 0:07




















            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%2f53529385%2fget-childitem-and-wildcards-and-filtering%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







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks