Powershell: Get-Item vs Get-ChildItem

Get-Item
Gets the item at the specified location.

Get-Item .\foo
# returns the item foo

Get-ChildItem
Gets the items and child items in one or more specified locations.

Get-ChildItem .\foo
# returns all of the children within foo

note: Get-ChildItem can also recurse into the child directories

Get-ChildItem .\foo -Recurse
# returns all of the children within foo AND the children of the children

enter image description here

enter image description here

enter image description here

Leave a Comment

tech