Questions tagged [get-childitem]

Get-ChildItem is a powershell cmdlet that gets the items and child items in one or more specified locations.

Get-ChildItem is a powershell cmdlet that gets the items and child items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child items. You can use the Recurse parameter to get items in all child containers.

A location can be a file system location, such as a directory, or a location exposed by a different Windows PowerShell provider, such as a registry hive or a certificate store.

Output

  • System.Object
    The type of object that Get-ChildItem returns is determined by the objects in the provider drive path.

  • System.String
    If you use the Name parameter, Get-ChildItem returns the object names as strings.

520 questions
10
votes
3 answers

How to write a PowerShell function to get directories?

Using PowerShell I can get the directories with the following command: Get-ChildItem -Path $path -Include "obj" -Recurse | ` Where-Object { $_.PSIsContainer } I would prefer to write a function so the command is more readable. For…
Tim Murphy
  • 4,892
  • 4
  • 40
  • 48
9
votes
1 answer

Why does Test-Connection force enumeration of reparse points?

I've noticed some behavior in PowerShell that I can't explain, but I'm hoping that someone else can. If I want to build a list of file objects from drive C:\, and I want to ignore shortcut folders (reparse points) such as C:\Documents and Settings\.…
Van Vangor
  • 398
  • 3
  • 9
9
votes
4 answers

Extract lines matching a pattern from all text files in a folder to a single output file

I am trying to extract each line starting with "%%" in all files in a folder and then copy those lines to a separate text file. Currently using this code in PowerShell code, but I am not getting any results. $files = Get-ChildItem "folder" -Filter…
9
votes
6 answers

Recyclerview, I can't get item view with getChildAt(position). Null object reference

I am using a recyclerView inside my navigation drawer and I am using this library Twoway-view to get click and selection support. It works perfectly and I can change the color of the text and the icons without problems inside OnClick method for each…
JavierSegoviaCordoba
  • 6,531
  • 9
  • 37
  • 51
9
votes
1 answer

Powershell - using wildcards to search for filename

I am trying to make a PowerShell script that will search a folder for a filename that contains a certain file-mask. All files in the folder will have format like *yyyyMd*.txt. I have made a script: [String]$date = $(get-date -format yyyyMd) $date1…
Phil E
  • 93
  • 1
  • 1
  • 5
9
votes
1 answer

"[" and "]" characters mess up get-childitem

Using PowerShell 4.0, I am trying to get the size of multiple directories and I am getting very inconsistent results between what windows tells me and what my code is telling me. The code in question is: $temp4 =…
LuckyFalkor84
  • 547
  • 1
  • 5
  • 14
9
votes
4 answers

In powershell, how can I use Rename-Item to output the old and new file names at the same time?

I'd like to select a list of files using Get-ChildItem piped to Rename-Item and have the output display text with each line showing something like "Renamed oldfilename to newfilename". How can I do this?
James World
  • 29,019
  • 9
  • 86
  • 120
8
votes
2 answers

Powershell Get-ChildItem progress question

So, I've got a set of directories 00-99 in a folder. Each of those directories has 100 subdirectories, 00-99. Each of those subdirectories has thousands of images. What I'm attempting to do is basically get a progress report while it's computing…
Tejs
  • 40,736
  • 10
  • 68
  • 86
8
votes
1 answer

Powershell script to count specific files in directories & subdirectories

I am trying to make a powershell script which will count all the .xml files in directories & subdirectories and list the value + path. So far I have done the this: Get-ChildItem -Path c:/test -recurse -include *.xml Which is close to what I want…
daelas
  • 183
  • 1
  • 1
  • 6
8
votes
2 answers

How do I prevent Get-ChildItem from traversing a particular directory?

Let me start by saying that I've looked at Unable to exclude directory using Get-ChildItem -Exclude parameter in Powershell and How can I exclude multiple folders using Get-ChildItem -exclude?. Neither of these has an answer that solves my…
jpmc26
  • 28,463
  • 14
  • 94
  • 146
8
votes
2 answers

Powershell Get-ChildItem -recurse doesn't get all items

I'm working on a powershell script erase certain files from a folder, and move the rest into predefined subfolders. My structure looks like this Main (Contains a bunch of pdb and dll files) -- _publish --Website (Contains…
Daniel Olsen
  • 1,020
  • 2
  • 15
  • 27
7
votes
1 answer

PowerShell Get-ChildItem on folder that does not exist behaves different with the -recurse flag

I am testing a Power Shell script to clean out a folder and I noticed some unexpected (to me) behavior when i used the - recurse flag I have read the help files and done some searching but cant find an explanation for what is happening…
Brett Manners
  • 230
  • 1
  • 12
6
votes
1 answer

How to write a list sorted lexicographically in a grid listed by column?

I have the result of Get-ChildItem, and I want to iterate over these, and display their names. By default if I simply use Write-Host then I get it listed out along the row like this: PerfLogs Program Files Program Files (x86) Python31 Temp …
esac
  • 24,099
  • 38
  • 122
  • 179
6
votes
2 answers

piping get-childitem into select-string in powershell

I am sorting a large directory of files and I am trying to select individual lines from the output of an ls command and show those only, but I get weird results and I am not familiar enough with powershell to know what I'm doing wrong. this approach…
shieldfoss
  • 886
  • 2
  • 12
  • 22
5
votes
2 answers

How to avoid an UnathorizedAccessException when using Get-ChildItem?

I am using PowerShell 5.0 and working on a script to find and list all the versions of log4net.dll under the current directory recursively. Get-ChildItem log4net.dll -Recurse | % versioninfo | Export-Csv "C:\MyJunk\log4net.csv" The above statement…
1
2
3
34 35