![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | What is the syntax for piping LiteralPath to Get-ChildItem According to the help this does accept pipeline input as long as it's by name. However I've tried the either of these and had no success. '-LiteralPath c:\' | GetChildItem or a more complex expression '-LiteralPath "C:\Program Files"' | GetChildItem In each case the results are the same. Get-ChildItem reports the error that it can't find the drive specified in the pipe. thx bob (output from trace-object) ...... DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Get-ChildItem] DEBUG: ParameterBinding Information: 0 : PIPELINE object TYPE = [System.String] DEBUG: ParameterBinding Information: 0 : RESTORING pipeline parameter's original values DEBUG: ParameterBinding Information: 0 : Parameter [Path] PIPELINE INPUT ValueFromPipeline NO COERCION DEBUG: ParameterBinding Information: 0 : BIND arg [-literalpath 'c:\'] to parameter [Path] ..... Get-ChildItem : Cannot find drive. A drive with name '-literalpath 'c' does not exist. At line:1 char:84 + trace-command -name parameterbinding,cmdlet -expression {"-literalpath 'c:\'" | gci} <<<< -pshost |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem On Oct 6, 4:59 am, Bob Landau <BobLan...@xxxxxx> wrote:
name. This means that the object on the pipeline has to have a property named LiteralPath in order for Get-ChildItem's LiteralPath parameter to be filled. The object you are sending it is just a string, so it doesn't have this information. Contrast this with Get- ChildItem's Path parameter, which can also take input by value. This is why the following will work: "C:\Program Files" | Get-ChildItem Jeff | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) |
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem Complementing Jeff's answer with a sample: ByPropertyName means that the piped object must have a property name equal to the Cmdlet's parameter. # create a new dir whose name contains brackets, as you know # get-childItem's -path parameter will not 'get' these items, # need to use -literalPath new-item c:\ -name test[1] -type directory # create a few child items in it 0..4 | % {new-item c:\test``[1``] -n file$_.txt -t file} # no results get-childItem C:\test[1] # eventhough they do exist get-childItem -literalPath C:\test[1] # # # # # # # # # # # # # # # # # # # -< obj.csv >- # Name,LiteralPath # "test[1]","C:\test[1]" # "Program Files","C:\Program Files" # -< obj.csv >- # # # # # # # # # # # # # # # # # # # create an object from a CSV file that contains # a field named LiteralPath $obj = import-csv obj.csv # get-childItem takes that value byPropertyName # when the object is piped to it $obj | get-childItem # remove test dir and its children remove-item -literalPath C:\test[1] -recurse -- Kiron |
My System Specs![]() |
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem This does make sense (like most things in hindsight) Unfortunately it does make it more difficult to construct ad-hoc pipe parameters Regardless you explaination is Much Appreciated. thx bob "Jeff" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem Thank you Kiron, Both you and Jeff have help me understand this better. I know need to take your exampe and work with it bob "Kiron" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #6 (permalink) |
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem Glad to help Bob. I used export-csv to create the object in the sample, but you could also create a LiteralPath property for DirectoryInfo and FileInfo objects through PowerShell's ETS or add a member to a live object with add-member. Also, to save and later retrieve custom objects you can use export-csv, export-cliXml and import-csv, import-cliXml respectively. -- Kiron |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: What is the syntax for piping LiteralPath to Get-ChildItem Excuse the mistake: I used import-csv ... -- Kiron |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| bug: get-acl, rename-item missing the LiteralPath parameter | Hal Rottenberg | PowerShell | 0 | 06-29-2008 05:45 PM |
| One more question on -LiteralPath and -Include/-Exclude for GetChi | Bob Landau | PowerShell | 4 | 10-08-2007 01:31 PM |
| -LiteralPath is a less than optimal solution | Keith Hill [MVP] | PowerShell | 9 | 05-12-2007 12:57 AM |
| All about piping | Marco Shaw | PowerShell | 2 | 11-20-2006 11:20 AM |
| New to ps object piping | Adam Murray | PowerShell | 2 | 09-14-2006 02:14 AM |