1
$path='C:\Desktop\f'
$r=Get-ChildItem -Path $path -Filter *.deb

for($i=0; $i -lt $r.Count; $i++){
do { 
  get-content $r[$i] 

this is a pseudo code of the program I am trying to write the path I am trying to fetch is on desktop in a folder called f

but $r[$i] is different for example

the error as is

get-content : Cannot find path 'C:\Desktop\6747.deb' because it does not exist.
At C:\Desktop\deb.ps1:7 char:3
+   get-content $r[$i]| % {

even though my path is in desktop folder f why is it just going till dekstop and not any further

the deb.ps1 file is present on the desktop

2 Answers 2

1

Your problem is that $r is a list of objects, not file names. Try this instead:

Get-Content $r[$i].FullName
Sign up to request clarification or add additional context in comments.

Comments

0

Even easier is to use a pipe:

$r[i] | get-content

or to simplify the whole script:

$path='C:\Desktop\f'
Get-ChildItem -Path $path -Filter *.deb | get-content

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.