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
3
votes
1 answer

Exclude one folder and a filetype from Get-childitem

I have a website that needs frequent backup hence I would like to write a script to compress all the files in the screenshot. Except: All the contents in the image folder (See Highlighted) Any *.log files in the entire directory I tried to get a…
Muhammedh
  • 484
  • 1
  • 11
  • 25
3
votes
2 answers

Get-ChildItem registry key, extract key name only

I can get a key in the Uninstalls key of the registry, for a specific installed program, like this... $displayName = 'Parallels Tools' $key = 'Registry::HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall' Get-ChildItem -Path:$key |…
Gordon
  • 6,257
  • 6
  • 36
  • 89
3
votes
1 answer

Powershell - Using wildcards in path to search for filename in a specific subfolder

Extension of the post Powershell - using wildcards to search for filename Hi There! Let's assume we have this files and folders…
Only 4Info
  • 31
  • 2
3
votes
1 answer

How to exclude files and folders from Get-ChildItem in PowerShell?

I've made a PowerShell script that runs robocopy with md5 checks. It works fine, but if I try to exclude some dirs or files, robocopy handles the exclusion, whereas MD5 part of script that compares the hash, doesn't work, returns some errors because…
ilRobby
  • 69
  • 2
  • 10
3
votes
1 answer

PowerShell: Get-Item vs Get-ChildItem output types

I was trying to print out environment variables in alphabetical order (by name), and the first thing I could come up with was: Get-Item env: | Sort-Object -Property Name But the output was always unsorted. Then I tried the following Get-ChildItem…
huoneusto
  • 1,164
  • 1
  • 8
  • 19
3
votes
3 answers

Powershell unable to exact match folder full name

I have a script to get all the files inside the folder by using powershell get-childitem command. I am using the pipeline with match parameter to filter the file name as follows: Get-ChildItem -Path \\path\* -recurse | Where-Object {$_.FullName…
Yong Cai
  • 143
  • 1
  • 17
3
votes
2 answers

Why would Get-ChildItem -Recurse | Remove-Item work?

I've seen on a lot of places (for example, here, here, or here) where people suggest to use Get-ChildItem -Path "Some path" -Recurse | Remove-Item to recursively delete a directory, but why would this work? When I run Get-ChildItem -Path "foo"…
LanYi
  • 169
  • 3
  • 13
3
votes
3 answers

How to get Get-ChildItem to handle path with non-breaking space

I have the following code that works for most files. The input file (FoundLinks.csv) is a UTF-8 file with one file path per line. It is full paths of files on a particular drive that I need to process. $inFiles = @() $inFiles += @(Get-Content…
Sandra
  • 608
  • 2
  • 11
  • 23
3
votes
1 answer

get-childitem variable return empty value when running is powershell script

$NewestFile = $NULL $path = "C:\myDirectory" $NewestFile = Get-ChildItem -filter “FileName*.xlsx” -recurse -path $path | Sort LastWriteTime -Descending | Select -First 1 Write-Host " NewestFile" $NewestFile I have several files with nearly…
ksten
  • 31
  • 2
3
votes
1 answer

Powershell, ftp, get-childitem

Little new to powershell. I am trying to locate a get-childitem like command that will work on an ftp site. Here is some psuedo-code: $target = "c:\file.txt" $username = "username" $password = "password" $ftp =…
James
  • 572
  • 3
  • 9
  • 17
3
votes
0 answers

Referencing buttons inside Child Items in an Expandable List android

I have an Expandable List in my app. It has multiple Child Items and each Child Item Row is required to have 5 buttons. I have achieved this much so far. The problem is I get a count from a webservice which tells me the total number of buttons I…
3
votes
2 answers

Avoid recursively fetching specific folders in PowerShell

I have a Visual Studio solution with several projects. I clean up the bin and obj folders as part of clean up using the following script. Get-ChildItem -path source -filter obj -recurse | Remove-Item -recurse Get-ChildItem -path source -filter bin…
user1145404
  • 285
  • 1
  • 3
  • 9
3
votes
1 answer

PathTooLong error with Get-ChildItem in PowerShell v3, but not v2

On a Windows Server 2008 R2 VM, I upgraded PowerShell to v3 hoping to take advantage of the Get-ChildItem (gci) performance improvement. This line ran without error in v2: $search = gci $dir -recurse -exclude "*.mdf" | where {$_.length -gt…
noam
  • 1,914
  • 2
  • 20
  • 26
3
votes
1 answer

Copying files and creating new folders based on "creationdate"

I am counting all files in my Pictures folder with Get-ChildItem C:\pictures -force | Group-Object extension | Sort-Object count -descending | ft count,name -auto I am then copying all my MTS-files (video) to a separate folder with Get-ChildItem…
Sune
  • 3,080
  • 16
  • 53
  • 64
2
votes
2 answers

Get-Childitem using lots of memory

i know there are lots of threads already to this topic and i tried to put all the ideas into my powershell code as well to make get-childitem less memory hungry but still it eats up a lot of memory. Here is my thing: Having a directory with more…
marcuse
  • 21
  • 3