Invoke-command and get-childitem issue

Welcome Forums General PowerShell Q&A Invoke-command and get-childitem issue

This topic contains 1 reply, has 2 voices, and was last updated by

3 weeks, 3 days ago.

  • Author
  • #179748

    Topics: 2
    Replies: 0
    Points: 24
    Rank: Member


    Scenario 1) I am using Get-childitem command to get the files and folders from the specified path.

    Get-ChildItem -path "C:\Users" -recurse -force

    Above command is providing a satisfactory result. But, I am getting error in Scenario 2.

    Scenario 2) I am using the above command with Invoke-Command and getting an undesired output.

    Invoke-Command -computername "Mycomputer" -scriptblock{Get-ChildItem -path "C:\Users" -recurse -force}


    My findings till now

    When only using scenario 1, By default, the Get-ChildItem cmdlet displays symbolic links to directories found during recursion, but does not recurse into them.

    When I am using the scenario 2, It is not following the Get-ChildItem this behavior and it is doing the recursion.


  • #179853

    Topics: 1
    Replies: 1552
    Points: 2,700
    Helping Hand
    Rank: Community Hero

    and getting an undesired output.

    What does that mean? Do you try to run this command remotely to another computer?

You must be logged in to reply to this topic.