{"id":8241,"date":"2007-03-21T23:08:57","date_gmt":"2007-03-21T23:08:57","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/03\/21\/test-path-we-goofed\/"},"modified":"2019-02-18T13:16:47","modified_gmt":"2019-02-18T20:16:47","slug":"test-path-we-goofed","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/test-path-we-goofed\/","title":{"rendered":"Test-Path: We Goofed"},"content":{"rendered":"<p><span style=\"font-family:Tahoma;font-size:10pt\">Test-Path: We Goofed!<br \/>\u00a0\u00a0\u00a0\u00a0(also known as a documentation errata\u2026)\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">Test-Path is a very handy little cmdlet. You submit a path and it tells you (TRUE\/FALSE) whether the elements of the path exist on the computer. You can use it to determine whether particular files or folders are present (or missing) or to look for a registry key that indicates that a program is installed, among so many other uses.\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">My favorite Test-Path command reminds me when I&#8217;ve forgotten to copy my Windows PowerShell profile to one of my test machines (test-path $profile).\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">Test-Path is so good that there was no need to exaggerate its abilities in the docs, but we did. The following <strong>false<\/strong> statement appears in the description of the Leaf value of the PathType parameter:\n<\/span><\/p>\n<p style=\"margin-left: 36pt\"><span style=\"font-family:Tahoma;font-size:10pt\">&#8220;An element that does not contain other elements, such as a file or <strong>registry entry<\/strong>.&#8221;\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">That&#8217;s just not true. File, yes; registry entry, no.\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">Test-Path can detect registry <em>keys<\/em> (the containers), but it cannot detect registry <em>entries<\/em> (sometimes called &#8220;values&#8221;) or the data in an entry. If you try, it always returns FALSE.\n<\/span><\/p>\n<p style=\"margin-left: 36pt\"><span style=\"font-family:Tahoma;font-size:10pt\"><br \/><\/span><span style=\"color:black;font-family:Lucida Console\"><span style=\"font-size:10pt\">&#8216; Testing a registry key<br \/>C:\\PS&gt; test-path HKLM:\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell<br \/>True<br \/>&#8216; Testing a registry entry<br \/>C:\\PS&gt; test-path HKLM:\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell\\ExecutionPolicy<br \/>False<\/p>\n<p>&#8216; Finding the registry entry<br \/>C:\\PS&gt; get-itemproperty -name ExecutionPolicy -path HKLM:\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell<\/p>\n<p>PSPath          : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Micro<br \/>                  soft.PowerShell<br \/>PSParentPath    : Microsoft.PowerShell.Core\\Registry::HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds<br \/>PSChildName     : Microsoft.PowerShell<br \/>PSDrive         : HKLM<br \/>PSProvider      : Microsoft.PowerShell.Core\\Registry<br \/><strong>ExecutionPolicy : RemoteSigned<br \/><\/strong><\/span><span style=\"font-size:9pt\">\n\t\t\t<\/span><\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">(You&#8217;re using <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/04\/26\/584551.aspx\">TAB completion<\/a> on these paths, right?)\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">I&#8217;ve corrected the docs and added an example demonstrating this limitation. You&#8217;ll see it in the next release of Windows PowerShell.\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">I&#8217;m really grateful to the kind user who reported this error. If you find an error (or any other problem) with the docs, please report it using the instructions <a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/05\/09\/filing-bugs.aspx\">HERE<\/a>  First, I&#8217;ll feel really contrite, and then I&#8217;ll fix it, but I&#8217;ll be eternally grateful.\n<\/span><\/p>\n<p><span style=\"font-family:Tahoma;font-size:10pt\">June Blender [MSFT]<br \/>Senior Programming Writer<br \/>Windows PowerShell<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Test-Path: We Goofed!\u00a0\u00a0\u00a0\u00a0(also known as a documentation errata\u2026) Test-Path is a very handy little cmdlet. You submit a path and it tells you (TRUE\/FALSE) whether the elements of the path exist on the computer. You can use it to determine whether particular files or folders are present (or missing) or to look for a registry [&hellip;]<\/p>\n","protected":false},"author":600,"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-8241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Test-Path: We Goofed!\u00a0\u00a0\u00a0\u00a0(also known as a documentation errata\u2026) Test-Path is a very handy little cmdlet. You submit a path and it tells you (TRUE\/FALSE) whether the elements of the path exist on the computer. You can use it to determine whether particular files or folders are present (or missing) or to look for a registry [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8241","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\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=8241"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8241\/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=8241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=8241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=8241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}