filepath - Powershell's Join-Path Errs when Passing Path via Pipeline -
filepath - Powershell's Join-Path Errs when Passing Path via Pipeline -
join-path
allegedly accepts path
parameter pipeline.
this suggests 2 functions below should both work alike:
join-path 'c:\temp' 'x' #returns c:\temp\x 'c:\temp' | join-path 'x' #throws error
however sec phone call (i.e. using passing path parameter value pipeline) gives below error:
join-path : input object cannot bound parameters command either because command not take pipeline input or input , properties not match of parameters take pipeline input. @ line:1 char:13 + 'c:\temp' | join-path 'x' + ~~~~~~~~~~~~~ + categoryinfo : invalidargument: (c:\temp:string) [join-path], parameterbindingexception + fullyqualifiederrorid : inputobjectnotbound,microsoft.powershell.commands.joinpathcommand
nb: since path
may array tried [array]('c:\temp') | join-path 'x'
; made no difference.
have misunderstood something, or bug in powershell?
in first example, look join-path 'c:\temp' 'x'
interpreted powershell join-path -path 'c:\temp' -childpath 'x'
(because names positional parameters path
, childpath
optional).
in sec example, passing pipeline parameter 'c:\temp'
command join-path -path 'x'
(not absence of childpath
parameter). not work because join-path
accepts path
parameter pipeline have defined it.
if want bind another, not first parameter, should write name explicitly, in
'c:\temp' | join-path -childpath 'x' # => 'c:\temp\x'
powershell filepath powershell-v4.0
Comments
Post a Comment