Get-ChildItem Vs. Get-Content

Welcome Forums General PowerShell Q&A Get-ChildItem Vs. Get-Content

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

11 months, 1 week ago.

  • Author
  • #96107

    Points: 64
    Rank: Member

    What's the difference between these two commands?

    If I do

    Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Office"

    it shows the items, but if I do

    Get-Content -Path "C:\Program Files (x86)\Microsoft Office"

    it says "Get-Content : Access to the path 'C:\Program Files (x86)\Microsoft Office' is denied."

  • #96110

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Get-ChildItem retrieves directory listings.

    Get-Content reads text files.

    "C:\Program Files (x86)\Microsoft Office" isn't a file. It's a folder. Folders don't have 'contents.' They have _child items_, like files and other folders.

  • #96113

    Points: 64
    Rank: Member

    Thank you, makes sense now

The topic ‘Get-ChildItem Vs. Get-Content’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort