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

Powershell Get-ChildItem cmlet with '-recurse' optional

I'm trying to figure out if it's possible to use the parameter -Recurse into Get-ChildItem cmdlet depending on a value of another variable. I mean, let's say that we have the boolean parameter $flag, if $flag is True I would like to insert the…
-1
votes
1 answer

Find files and exit if file no exist in powershell

Have some simple script: $sql = Get-ChildItem -Path "C:\files\" -Filter *.sql In C:/files/ can be: 1. No file. (my issue) One file (test.sql) Multiple files. (test1.sql , test2.sql , etc) For 3 i'm using if ($sql.Count -gt 1 ) and its working…
Sinai R.
  • 33
  • 10
-1
votes
2 answers

PowerShell Get-ChildItem -Exclude and -Include not working

Can someone tell me what is going on here? I can get -Filter *.log to work no problem. PS C:\logs> Get-ChildItem -Filter *.log -Recurse Directory: C:\logs Mode LastWriteTime Length Name ---- ------------- …
shaun
  • 1,223
  • 1
  • 19
  • 44
-1
votes
1 answer

Get line and line number from Select-String

I have this script which works great, but I would also need it to return the line number and the line. If I do Select-String w:\test\york\*.* -pattern "mistake" I get W:\test\york\test.html:179:

If you notice a mistake on an information slip,…

JonYork
  • 1,223
  • 8
  • 31
  • 52
-1
votes
1 answer

How to use Get-ChildItem in Powershell v4 vs v2

It might be that the title of the question is somewhat misleading, but I suspect that there has been done some changes from 2.0 to 4.0 which I am not aware of...so here goes The following code will provide me with the expected result on our Windows…
rhellem
  • 769
  • 1
  • 11
  • 26
-1
votes
2 answers

Powershell (v2) Path grave-accent (escape character) conflicting with Get-ChildItem

I have a friend with a video on my computer. The path is C:\Users\Me\Videos\Tonys Videos\Dinosaur [1080p]\ In the Dinosaur movie folder is an "asset" folder, which contains a few .gif,.jpg and .png files. I wanted to learn a little bit about…
JoeDaHobo
  • 25
  • 1
  • 1
  • 5
-1
votes
1 answer

Powershell get links from .txt file, grab source, get string, export to csv

In order, I have to: 1) grab all links from txt file http://example1.htm http://example2.htm http://example3.htm ... 2) get source from each link 3) get my strings from source 4) export strings to csv It works with one link. Example: $topic1…
-1
votes
3 answers

as3 can I do this on one line

Hi I can go this var firstname = firstname_mc; var fname = firstname.getChildAt(0).text; but var firstname = MovieClip(firstname_mc).getChildAt(0).text; does not work
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
-2
votes
1 answer

Powershell search for text in files

I have a problem. I'm going to search files on my computer for keywords in the files. The keyword is for example "C:\Project". I get error when running this script below. But when i'm deleting C:\ in the search string it's working. But i'm…
-3
votes
1 answer

How to dynamically know location in a PowerShell script

I am using Get-ChildItem to navigate through a directory with the intention of recording file paths to a text file. However, I want to create the text files dynamically based on whether I'm in a specific folder or not. For example, let's say this is…
gsamerica
  • 153
  • 1
  • 3
  • 18
1 2 3
34
35