Questions tagged [get-childitem]

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

Filter by
Sorted by
Tagged with
0 votes
2 answers
48 views

Putting a for each loop inside a foreach loop

I have the need to search all servers in our domain for specific folders, I already have a script here function Find-ComputersWithFolder { # Get all computers in the Active Directory domain $...
Martyn Jeffrey's user avatar
1 vote
1 answer
50 views

Get-ChildItem with specific properties, but still grouped by (sub)folder

I have written this bit of PowerShell code to get a listing of files meeting the type criteria shown below: Get-ChildItem -Path 'C:\Program Files\Common Files' -Recurse -Include *.exe, *.bat, *.com, *....
Sigshane's user avatar
3 votes
1 answer
114 views

Using Powershell runspaces to search large number of files (.XML)

I have a script that will look for a regex inside a large number of files, such as an address or phonenumber. The script i currently have runs as a job and works, however very slowly. Currently my ...
iva hardy's user avatar
2 votes
1 answer
71 views

Powershell move folders with exclude

I have a lots of folders with contents that I want to move to another folder Below I want to move the 3 folders to the ARKIV folder - it works but the script crasches at the end. Am I using the ...
Henrik Rosqvist's user avatar
-2 votes
1 answer
26 views

What would make a script to get stdout returns differently on different locations?

import * as path from "https://deno.land/[email protected]/path/mod.ts"; async function getStdout() { const dirname = path.dirname(path.fromFileUrl(import.meta.url)) const cmd = new Deno....
Ooker's user avatar
  • 2,190
1 vote
1 answer
42 views

How to change default view of FileInfo and DirectoryInfo?

I want to set a default strategy for displaying FileInfo and DirectoryInfo objects in Powershell to display only file paths. Default behaviour PS C:\Users\user> gci Directory: C:\Users\user ...
Podbrushkin's user avatar
0 votes
0 answers
37 views

Google App Script - XML Parse - Can not get elements from 4th Child level

I Have this HTML, from google drive. <rDE xmlns="http://ekuatia.set.gov.py/sifen/xsd" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/...
William Belini's user avatar
0 votes
2 answers
43 views

Unity GetComponentInChild

I'm trying to create an inventory system. I have an Item class, and I want to change the visual appearance of the slot I create based on the data in this class, but it's not working. Where am I making ...
erdem.61's user avatar
0 votes
1 answer
117 views

PowerShell switch return missing file based on group

In theory, now that all the files in the '2023' folders have the same number of elements in the file name I can get an inventory. See my previous post for reference btw thanks @mklement0 it said not ...
cthorn112's user avatar
2 votes
2 answers
93 views

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. ...
marcuse's user avatar
  • 21
3 votes
3 answers
121 views

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 -...
kindzmarauli's user avatar
0 votes
1 answer
77 views

power shell script to exclude onedrive folder

power shell script to exclude onedrive folder # Define the root folder to scan $rootFolder = "C:\Users" # Get all files in the root folder and its subdirectories, excluding OneDrive folder $...
Ram Chandra Murmu's user avatar
2 votes
1 answer
109 views

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

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 ...
Eric's user avatar
  • 23
0 votes
0 answers
42 views

Get-ChildItem to get line count of multiple csv's in Powershell without outputting the full path

I'm trying to get the line count of multiple CSV files exported to a CSV file. But it keeps outputting the full path. This is my Powershell code: $FullPath = "\\Space\folder1\folder2" $...
noobCoder's user avatar
  • 103
0 votes
0 answers
114 views

Powershell Get-ChildItem not returning all files in network folder

I try to list the files in a network drive for further processing, but it seems Powershell misses out on some files: Checking the Folder from Explorer in Windows, I see 61 items. But when using ...
McMaster's user avatar
1 vote
1 answer
214 views

Powershell get-childitem works different with long-path prefix (\\?\)

I have different results in these two cases: case 1: Get-ChildItem -Path "\\?\UNC\very\long\path" case 2: Get-ChildItem -Path "\\very\long\path" If the long path is less than 260 ...
toscanelli's user avatar
  • 1,212
0 votes
1 answer
69 views

How Can I Suppress the Tabular Output from PowerShell’s Get-ChildItem?

When calling Get-ChildItem during my latest test, its default tabular output returns entries for over 10,000 files, and makes the important data scroll off the top of the console. Not only that, but ...
aksarben's user avatar
  • 600
0 votes
1 answer
26 views

Excluding folder and contents when using get-child items -exclude not working

I want the script to go through a specific path and exclude one specific folder and its contents. I then want it to delete all .pdf files older than 3 days. The filtering and deletion works as ...
NullCool's user avatar
0 votes
1 answer
220 views

How to create a script that will access all folders, subfolders and unzip the files to read the log

I am trying to create a script that it will access a directory and check all the folders, but inside those folders are zip files that need to be unzipped, after that I will read the log file searching ...
Brazs's user avatar
  • 35
1 vote
1 answer
94 views

Powershell : Get-ChildItem piped to Select-Object returns null Directory property when selecting directory

I am using the Get-ChildItem cmdlet with the -Recurse parameter to enumerate all files and directories in a specific path. If I run : (Get-ChildItem -Path $Path -Recurse | Where-Object -Property ...
Silloky's user avatar
  • 157
1 vote
1 answer
87 views

How to exclude multiple folders in PowerShell in Get-ChildItem to look and delete duplicated files

I am trying to search and delete duplicate files in a root Directory, but I don't want the script look for some subdirectorys. My code is this but it fails when I run it: $srcDir = "rootDir" ...
jamyandy_1500's user avatar
2 votes
3 answers
224 views

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)\$($_....
Ralph Warner's user avatar
0 votes
1 answer
63 views

Powershell: How would I create multiple scripts that read and move files from the same directory to individual Folders?

I'm trying to write a read and move function that can be placed in different scripts that will read and move from one shared folder (there's around 200k to 700k files in this directory). So 3 or more ...
Jay's user avatar
  • 11
1 vote
2 answers
273 views

With PowerShell, how do I insert a header row to the first line of a text file?

I was able to prepend the file with the content of $newstring. $sourceDirectory = "C:\SFTP_Root\kcmosdftp\" $keyword = "User_ID|User_Alt_ID" $newString = "User_ID|User_Alt_ID|...
Ruben E Noguera's user avatar
-1 votes
1 answer
84 views

Cannot output file info with get-childitem when using variable for computer name

I am trying to read a list of computers from a .txt file, then look for a specific file named engage.* that exists in a specific directory on the pcs, then output the file info for engage.* to a csv ...
EBoone's user avatar
  • 9
1 vote
1 answer
178 views

PowerShell | Argument completer not working when a file with the required criteria is not in the current working directory

I've tried 2 argument completers so far for my module to only show me the files with .cer extension when I press TAB button. Here is one of them $ArgumentCompleterCertPath = { Get-ChildItem | ...
SpyNet's user avatar
  • 404
0 votes
1 answer
219 views

Get-Childitem using shared folders

I have a script to copy some files and child items from a network computer to a shared drive and I am using this: #(ComputerName) Not real name, for security reasons. #(ParentFolderName) Not real name,...
AaronD's user avatar
  • 1
0 votes
1 answer
49 views

How to copy a pictures but only certain filename with powershell

H want to copy some photos from a folder to another. in the folder has a lot of photos, but I only want to copy a certain filename that i input to a multiple textbox. this is what I did so far: ` $...
DeGun999's user avatar
0 votes
0 answers
68 views

Get-Childitem not working in directories with accentuation

I am try to get some ntfs permissions from directories using Get-ChildItem, but they do not seem to work when these directories contains accentuation. Unfortunately I am not allowed to rename the ...
jonas's user avatar
  • 23
1 vote
1 answer
66 views

How to apply condition to a string in the multiple string with powershell

I am trying to make a txt file and apply some content to a multiple string this is what I did so far: $Filename = "Jessica,Jimmy,Adam" $Content = ({Whoisthesmartest=}) $Splitname = get-...
DeGun999's user avatar
0 votes
1 answer
83 views

How to search for files and copy to new location with folder structure intact - Powershell

Using Powershell to search (Get-ChildItem) for specific files that you need to copy to a new location with the same folder structure seemed to be not trivial with Powershell. Combining Get-ChildItem ...
Steve Dorr's user avatar
1 vote
1 answer
119 views

Get-ChildItem exclude multiple full path

I'd like to use Powershell script that search files greater than 30GB. But I'd like to exclude from search, multiple files by full path. Files patchs are in external txt file. I try use -notike and -...
Adam's user avatar
  • 13
0 votes
0 answers
47 views

Get-Childitem including the directory itself [duplicate]

This is probably a dumb question but is there a way to get a directory and all of it's subdirectories using either Get-Item or get-ChildItem? Or would I need to use both? Ex. I have the following ...
RookieMistake's user avatar
1 vote
1 answer
981 views

Get-ChildItem using multiple paths, and retrieve all files that matches and their path - only the server name

I build a script that retrieve all files form specific paths that match a name, and also the path that the files are in. I want only to get the file name and the server name (Server-1, Server-2 etc..),...
Uriel Cohen's user avatar
0 votes
0 answers
28 views

Pulling lastwritetime from files across share drives

The goal is to find files across share drives that have a lastwritetime of this year. $creds = Read-Host "Input username" $dirs = get-WmiObject -class Win32_Share -computer fileshare....
Nate's user avatar
  • 802
0 votes
1 answer
59 views

how to display filesize in KB instead of bytes [duplicate]

Very happy with the result of this script however I would like the result to display like: example: Mode LastWriteTime Length Name ---- ------------- ---...
Codeman's user avatar
0 votes
1 answer
72 views

Get-ChildItem can't find dir when script run with -File instead of -Command

I had to change my script to use -File instead of -Command and it used to find the dir with GetChildItem but now it's not finding it. The script is called from an old old perl script, and this is ...
Michele's user avatar
  • 3,667
0 votes
1 answer
156 views

Powershell Get-ChildItem -Filter '*.txt' also finds '*.txt~' (too greedy?)

I'm on Windows 11 with Powershell vesrion 5.1.22621.963. I want to list the contents of a directory while filtering on files ending in ".txt". I try the following: > ls -Filter "*....
Stassa Patsantzis's user avatar
0 votes
1 answer
26 views

VisualStudioCode debugger says to supply values and gives prompt

I'm trying to use code to get files in a dir and choose the one(s) that are edited in the last 4 hours. For some reason, when I debug this in VisualStudioCode, the debugger says Supply values for the ...
Michele's user avatar
  • 3,667
0 votes
1 answer
59 views

How to use multiple include/exclude creiteria simultaneously in powershell?

I am using the following code to get files using include & exclude criteria: Get-ChildItem -Path Path/To/Folder -Include @("*Basic_TShirt_Men*",) -Exclude @("*black*","*...
dc09's user avatar
  • 416
0 votes
0 answers
28 views

Get-childitem specific

I’m trying to copy everything from folder2 to dest. Current structure: c:\root\folder1\folder2 C:\dest There are thousands of folder1s and thousands of folder2s under root. I need all the folder2s ...
Martina's user avatar
0 votes
1 answer
77 views

Check Modify Age of 100k files --> PathTooLongException

currently I am working on a script that should give me the number of files that have been modified in the last 30 days or between 30 and 180 days or that have not been modified for 180 days. So three ...
Telvanis's user avatar
0 votes
1 answer
498 views

Powershell List Excel Files and Copy

I apologize for the naivety of this post, please forgive my newness. I have approximately 20,000 network files to filter through and copy certain ones to a local drive. File List Requirements: Excel ...
blimbert's user avatar
-1 votes
1 answer
49 views

Reorganise folders [closed]

I have a folder with many subfolders (subfolder1). Under each subfolder1 is another subfolder (subfolder2) containing files. I want to remove the first level of subfolder1 so that all I have is ...
Martina's user avatar
1 vote
1 answer
44 views

Why doesn't my Powershell loop grab a PDF file if im calling -Include "*.pdf"

foreach ($file in Get-ChildItem -Path $srcRoot -File -Include "*.pdf" -Force -Recurse { Above is just a line out of my script that is moving files from one directory to another. Long story ...
Medium Rare's user avatar
0 votes
2 answers
84 views

Powershell script to replace pattern YY to YYYY

I am not the Powershell pro so I need some help. What I have now is for example: somelongname_08-01-01_someotherlongname.pdf and I want a rename to somelongname_2008-01-01_someotherlongname.pdf In ...
idontkn0w123's user avatar
0 votes
1 answer
249 views

Get the latest file and compare its filename with the rest of the files

I want to get the latest file in a directory and use its filename without the (Count) to check if it has same names with the rest of the files. If filename matches, Rename it as $(Get-Date -Format ...
jeriru's user avatar
  • 67
0 votes
0 answers
110 views

Anyone knowing a alternative for GetchildItem to select more than 3Million files in an folder? (Powershell 4.0)

I have a script that sort and zip Files in an folder by Year/Month. In normal folders its works fine with no errors but in folders with million files I get the error message: System....
Informatik's user avatar
0 votes
2 answers
296 views

Powershell Get-ChildItem Exclude Default Windows Folders

I want to search for files with .2fa extension on remote computers. I can find the files I want, but it takes a long time to get to the second computer because it scans all windows files. I tried the -...
virtue's user avatar
  • 13
0 votes
0 answers
163 views

PowerShell, Get-ChildItem formatted output

I have various simple functions like the below (this one outputs Size in 'human readable' format and the Name) and am curious on generic ways to format outputs for these functions. How can I make the ...
YorSubs's user avatar
  • 3,326

1
2 3 4 5
11