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

How can I check for the presence of .DLL files using cmd.exe or PowerShell, without changing permissions?

How can I check for the presence of these https://bugzilla.mozilla.org/show_bug.cgi?id=1841751#c4 .DLL files in C:\ProgramData and child containers, using cmd.exe or PowerShell? Preferably one-liners rather that scripts. Without changing access…
Eric
  • 23
  • 4
2
votes
3 answers

Can you use Get-ChildItem -Filter to filter by filename length?

Is something like the below example code possible? Get-ChildItem $copyFilePath -Filter $_.Basename.Length -ne 22 | forEach-Object{ Copy-Item -path "$($copyFilePath)\$($_.Fullname)" } I am trying to find a way to remove…
2
votes
4 answers

Create file list in every subfolder using PowerShell

I'm very new to PowerShell and have basically zero knowledge about PowerShell scripting, which is why I need some help. I have folder structure with subfolders (as shown below) for which I want to generate a filelist.txt in every 1st level subfolder…
redoXiD
  • 23
  • 1
  • 4
2
votes
1 answer

Copy select items from one folder to a new folder

I am getting all wav files in the past 24 hours from one folder and putting them in another folder. I swear this worked for me a bit ago and wanted to add in some more conditional statements but now it is working. It is not creating a new folder for…
2
votes
2 answers

Powershell find string that matches multiple criteria from an arraylist

Fairly new to PowerShell and am looking to figure out how to find a name of a directory that matches multiple criteria from an array list. The below code is what has been developed so far: $InputAddress = Read-Host -Prompt 'Enter in a job…
Screamcheese
  • 105
  • 1
  • 10
2
votes
1 answer

PowerShell script to combine CSVs and add root directory as an additional column

I'm trying to write my first PowerShell script and I'm struggling to get my head around the object orientation and piping approach. So I've got a directory structure like this (Google Takeout Nest directories): Path\DeviceID-A\ - Year\ -…
JamesM
  • 71
  • 1
  • 6
2
votes
3 answers

How can I improve the speed and memory usage of calculating the size of the N largest files?

I am getting the total number of bytes of the 32 largest files in the folder: $big32 = Get-ChildItem c:\\temp -recurse | Sort-Object length -descending | select-object -first 32 | measure-object -property length –sum $big32.sum…
2
votes
1 answer

powershell loop trough files and execute command against it

I'm figuring out how to loop trough a set of files and execute a program against these files, that outputs a log and tar file as it scans a hyper-v virtual hard disk. What I already figured out is the following: gathering all VHDX on a volume.…
loewie1984
  • 21
  • 7
2
votes
1 answer

Get-ChildItem return access denied error when run as "SYSTEM"

I'm trying to create a script to get content of a folder across the network. I noticed that Get-Childitem throw "Access Denied" error on every other IP addresses in the list. For example i listed the IP like this: IP1 IP2 IP3 IP4 Get-ChildItem…
Aaron
  • 57
  • 1
  • 8
2
votes
1 answer

Get-ChildItem different commands

What is the difference between the following commands in PowerShell? Get-ChildItem C:\Users -Directory Get-ChildItem C:\Users | Where-Object {$_.PSIsContainer -eq $true} They both seem to give the same results. Is there a difference at…
user15265939
2
votes
1 answer

Powershell Specify Minimum Search Depth

This question has actually come up for me a couple of times, and despite searching, I haven't been able to find an answer for it. I'm posting here because I've found a working solution that will hopefully help other users, but I'd also like to know…
Kraigolas
  • 5,121
  • 3
  • 12
  • 37
2
votes
0 answers

Powershell Get-Content file not found after Get-ChildItem

I am currently trying to read the metadata from an index server export with PowerShell to be able to tag a SharePoint document library with this information. First I search all XML files in the current directory: $XMLPaths = Get-ChildItem -Recurse…
2
votes
2 answers

Powershell splatting: pass ErrorAction = Ignore in hash table

Here's a script to list directories / files passed on the command line -- recursively or not: param( [switch] $r ) @gci_args = @{ Recurse = $r ErrorAction = Ignore } $args | gci @gci_args Now this does not work because Ignore is interpreted as…
usretc
  • 723
  • 4
  • 9
2
votes
2 answers

How to return files in powershell with the same extension, but containing a specific end to the name?

There are multiple .webp files in a project folder. Some .webps are the original picture and some function as thumbnail (their size is different). The used naming convention is: original files are just called NAME.webp and tumbnails are…
Hajo Brandt
  • 113
  • 7
2
votes
1 answer

List files by date in filename Powershell

I hope you are well. I am new in Powershell and am trying to make a script that allow to list files 7 days old based on the date in the filename, then copy/move them to another directory. File Structure: 2020_06_11_DB.txt YYYY_MM_dd I have this…