{"id":17636,"date":"2007-06-28T11:17:25","date_gmt":"2007-06-28T19:17:25","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17636"},"modified":"2019-05-16T11:19:07","modified_gmt":"2019-05-16T19:19:07","slug":"partying-with-join-path","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/partying-with-join-path\/","title":{"rendered":"Partying with Join-Path"},"content":{"rendered":"<p>Did you realize that you can Join-Path can work on multiple items?\nPS> Get-Help Join-Path -parameter *path<\/p>\n<p>-path <string[]>\nSpecifies the main path (or paths) to which the child-path is appended.\nWildcards are permitted.<\/p>\n<p>The value of Path determines which provider joins the paths and adds th\ne path delimiters. The Path parameter is required, although the paramet\ner name (-path) is optional.<\/p>\n<p>Required? true\nPosition? 1\nDefault value N\/A &#8211; The path must be specified\nAccept pipeline input? true (ByValue, ByPropertyName)\nAccept wildcard characters? true<\/p>\n<p>-childPath <string>\nSpecifies the elements to append to the value of Path. Wildcards are pe\nrmitted. The ChildPath parameter is required, although the parameter na\nme (-ChildPath) is optional.<\/p>\n<p>Required? true\nPosition? 2\nDefault value N\/A &#8211; The ChildPath must be specified\nAccept pipeline input? true (ByPropertyName)\nAccept wildcard characters? True\nLet&#8217;s get crazy!\nNotice that PATH accepts an array of STRINGS. This is what that allows you to do:\nPS> Join-Path C:\\hello world\nC:\\hello\\world\nPS> Join-Path C:\\hello,d:\\goodbye,e:\\hola,f:\\adios world\nC:\\hello\\world\nd:\\goodbye\\world\ne:\\hola\\world\nf:\\adios\\world\nNext, notice that PATH can be pipelined BYVALUE. That allows you to do:\nPS> Get-Content t1.txt\nc:\\hello\nd:\\Goodbye\ne:\\hola\nf:\\adios\nPS> Get-Content t1.txt | Join-Path -ChildPath world\nc:\\hello\\world\nd:\\Goodbye\\world\ne:\\hola\\world\nf:\\adios\\world\nNext, notice that ChildPath can be pipelined BYPROPERTYNAME. That allows you to do:\nPS> Get-Content t.csv\nChildpath\nWorld\nJeffrey\nMicrosoft<\/p>\n<p>PS> Import-Csv t.csv |Join-Path c:\\hello\nc:\\hello\\World\nc:\\hello\\Jeffrey\nc:\\hello\\Microsoft\nc:\\hello\\\nNext, remember that Path accepts an ARRAY of strings. This allows you to do:\nPS> Import-Csv t.csv |Join-Path c:\\hello,d:\\Good-Bye\nc:\\hello\\World\nd:\\Good-Bye\\World\nc:\\hello\\Jeffrey\nd:\\Good-Bye\\Jeffrey\nc:\\hello\\Microsoft\nd:\\Good-Bye\\Microsoft\nc:\\hello\\\nd:\\Good-Bye\\\nLastly, notice that both PATH and CHILDPATH can be pipelined BYPROPERTYNAME. That allows you to do:\nPS> Get-Content t2.csv\nPath,Childpath\nc:\\Hello,World\nd:\\Good-Bye,Jeffrey\ne:\\PowerShell-Rocks,Microsoft\nPS> Import-Csv t2.csv |Join-Path\nc:\\Hello\\World\nd:\\Good-Bye\\Jeffrey\ne:\\PowerShell-Rocks\\Microsoft\nSo now what you&#8217;ll want to do is to a bunch of Get-Help \u2013FULL and example the parameters and look for those that accept arrays of elements and those that accept pipeline input \u2013 then experiment.\nEnjoy!\nJeffrey Snover [MSFT]\nWindows Management Partner Architect\nVisit the Windows PowerShell Team blog at: http:\/\/blogs.msdn.com\/PowerShell\nVisit the Windows PowerShell ScriptCenter at: http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you realize that you can Join-Path can work on multiple items? PS> Get-Help Join-Path -parameter *path -path Specifies the main path (or paths) to which the child-path is appended. Wildcards are permitted. The value of Path determines which provider joins the paths and adds th e path delimiters. The Path parameter is required, although [&hellip;]<\/p>\n","protected":false},"author":685,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Did you realize that you can Join-Path can work on multiple items? PS> Get-Help Join-Path -parameter *path -path Specifies the main path (or paths) to which the child-path is appended. Wildcards are permitted. The value of Path determines which provider joins the paths and adds th e path delimiters. The Path parameter is required, although [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/685"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17636"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17636\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}