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
5
votes
2 answers

Exclude SubFolder in Get-ChildItem PowerShell Statement

I've been doing my best to get more familiar with PowerShell as a way to automate many of our regular tasks in an effort to eliminate human error. I support a web based application, and my current goal is to create a script to migrate the…
Christopher Cass
  • 817
  • 4
  • 19
  • 31
5
votes
2 answers

Get-ChildItem: Show only folders that do not include a specific file

First post on the platform ;-) Scenario: I have a root folder that contains subfolders with setup related files. Some subfolders contain more subfolders with more files, subsubfolders. Each of the subfolders underneath the root folder, or their…
user5197928
5
votes
1 answer

Determine recursively both COUNT and SUM of all extensions in a folder

I would like to be able to select a remote folder and scan it recursively for all file extensions. For each extension discovered, I would need a total count and well as the sum for individual file types. I've found a script here that works for a…
user2521736
  • 85
  • 1
  • 2
  • 6
5
votes
2 answers

powershell extend an object

How can I add a column to an object in PowerShell? For example, the Get-Childitem returns an object, with Mode, LastWriteTime, Length Name, etc.... And I want to extend this object with an extra column, that is computed from LastWriteTime. This is…
gazsiazasz
  • 355
  • 1
  • 4
  • 11
4
votes
1 answer

Rename-Item : Source and destination path must be different error in Powershell

I am using Powershell and trying to return the child item of a directory, which happens to be a subdirectory, and then use the Rename-Item cmdlet to rename the subdirectory name to something else. I feel like the following code should…
4
votes
3 answers

Powershell returns different information using remote connection

On my target computer in PowerShell I run command $FolderSize =(Get-ChildItem "C:\Users\JDoe" -force -Recurse -ErrorAction SilentlyContinue | Measure-Object length -sum).sum and I get a value of 0.76 gb, which accurately corresponds to the…
MusicMan
  • 65
  • 6
4
votes
5 answers

Use Powershell to list the Fully Pathed Filenames on Individual Separate Lines?

If I execute: Get-ChildItem *.ext -recurse the output consists of a series of Directory sections followed by one or more columns of info for each matching file separated by said directory sections. Is there something like the Unix find command? In…
Tim Hanson
  • 59
  • 1
  • 5
4
votes
1 answer

How do I use Get-ChildItem to return files that don't have an extension?

I want to get a list of files that don't have a filename extension. Consider the content of my directory to be: folder file1 file2.mp4 My goal would be to get file1 only. Running Get-ChildItem -Exclude *.* -File returned nothing. Running…
davidchoo12
  • 1,261
  • 15
  • 26
4
votes
1 answer

Powershell: Why does (gci c:\ddd).count on an Empty folder not return 0

Why does (gci c:\ddd).count on an Empty folder not return 0 but "nothing" I just get an Error "You cannot call a method on a null-valued expression." When my count-condition does not match. What do i need to "get" the zero to prevent the exception?
icnivad
  • 2,231
  • 8
  • 29
  • 35
4
votes
1 answer

Copy files where lastwritetime -ge 3/26/2010 9:00pm with Powershell

I need to copy files in one directory to another directory where the lastwritetime is greater than or equal to 3/26/2010 9:00pm. I'm using: Get-ChildItem C:\pstest\hlstore\folder1\data | where-object {$i.lastwritetime -ge “3/26/2010 9:00 PM”} |…
Emo
  • 486
  • 4
  • 9
  • 19
4
votes
1 answer

In PowerShell, how do I get all registry keys with a certain property?

I want to get the installation directories of all Visual Studio versions installed on a machine (to copy a file into the Xml/Schemas directory) The best way is to read from the registry. At \HKLM\Software\Wow6432Node\Microsoft\Visual Studio, all the…
ageektrapped
  • 14,482
  • 7
  • 57
  • 72
4
votes
3 answers

PSRemoting performance overhead with get-childItem

This completes in 2.3 minutes on LOCALSERVER: A: measure-command {$x = invoke-command {gci -recurse "C:\"}} This completes in 38.4 minutes on LOCALSERVER: B: measure-command {$x = invoke-command -comp LOCALSERVER {gci -recurse "C:\"}} Why is B…
noam
  • 1,914
  • 2
  • 20
  • 26
4
votes
3 answers

How to limiting files searched by Get-ChildItem (or limiting depth of recursion)?

Background There is a directory that is automatically populated with MSI files throughout the day. I plan on leveraging Task Scheduler to run the script shown below every 15 minutes. The script will search the directory and copy any new MSIs that…
wanderingandy
  • 823
  • 1
  • 8
  • 16
4
votes
3 answers

PowerShell Scripting - Get-ChildItem

I've written a script that will be used for archiving log files from a server. I'm in pretty good shape with everything but the recursiveness or not of Get-ChildItem... The issue I seem to be having is that when Get-ChildItem is not recursive and…
Bennett Dill
  • 2,875
  • 4
  • 41
  • 39
3
votes
3 answers

Powershell Get-ChildItem progress indication

Is it possible to display any sort of a progress indicator for the following (or similar) command? $dir = 'C:\$Recycle.Bin\S-1-5-18\' (Get-ChildItem -LiteralPath $dir -File -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property…
1 2
3
34 35