Powershell getting full path information -


i have directory called videos. inside directory, bunch of sub directories of various cameras. have script check each of various cameras, , delete recordings older date.

i having bit of trouble getting full directory information cameras. using following it:

#get of paths each camera $paths = get-childitem -path "c:\videos\" | select-object fullname 

and loop through each path in $paths , delete whatever need to:

foreach ($pa in $paths) {     # delete files older $limit.     $file = get-childitem -path $pa -recurse -force | where-object { $_.psiscontainer -and $_.creationtime -lt $limit }      $file | remove-item -recurse -force     $file | select -expand fullname | out-file $logfile -append } 

when run script, getting errors such as:

@{fullname=c:\videos\pc1-cam1} get-childitem : cannot find drive. drive name '@{fullname=c' not exist. @ c:\scripts\bodycamdelete.ps1:34 char:13 +     $file = get-childitem -path $pa -recurse -force | where-object { $_.psiscont ... +             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo          : objectnotfound: (@{fullname=c:string) [get-childitem], drivenotfoundexception + fullyqualifiederrorid : drivenotfound,microsoft.powershell.commands.getchilditemcommand 

is there way strip @{fullname= off of path? think may issue is.

share|improve question
up vote 4 down vote accepted

in case $pa object fullname property. way access this.

$file = get-childitem -path $pa.fullname -recurse -force | where-object { $_.psiscontainer -and $_.creationtime -lt $limit }  

however simpler change line , leave

$paths = get-childitem -path "c:\videos\" | select-object -expandproperty fullname 

-expandproperty return string instead of object select-object returning.

share|improve answer

you there. want -expandproperty argument select-object. return value of property, instead of fileinfo object 1 property, property being fullname. should resolve you:

$paths = get-childitem -path "c:\videos\" | select-object -expandproperty fullname 

edit: looks matt beat me minute.

share|improve answer

your answer

 
discard

posting answer, agree privacy policy , terms of service.

not answer you're looking for? browse other questions tagged or ask own question.

Comments