{"id":242,"date":"2010-03-25T08:07:03","date_gmt":"2010-03-25T13:07:03","guid":{"rendered":"http:\/\/nukeitmike.com\/blog\/2010\/03\/25\/not-recognized-as-a-cmdlet\/%20"},"modified":"2010-03-25T08:07:03","modified_gmt":"2010-03-25T13:07:03","slug":"not-recognized-as-a-cmdlet","status":"publish","type":"post","link":"https:\/\/blog.nukeitmike.com\/index.php\/2010\/03\/25\/not-recognized-as-a-cmdlet\/","title":{"rendered":"Not recognized as a cmdlet\u2026"},"content":{"rendered":"<p>I have been working on a simple little script to copy a file and then launch a program.&#160; I am sure that there are a lot of ways to do it, but I decided to use PowerShell, and this is what I came up with:<\/p>\n<blockquote>\n<p>$CheckForFile = &quot;H:\\custom.ini&quot;     <br \/>$FileToCopy = &quot;c:\\IT\\custom.ini&quot;      <br \/>$CopyFileTo = &quot;H:\\&quot; <\/p>\n<p>$PathTest = Test-Path $CheckForFile      <br \/>If ($PathTest -eq &quot;false&quot;)      <br \/>&#160;&#160;&#160; {      <br \/>&#160;&#160;&#160; Copy-Item $FileToCopy $CopyFileTo      <br \/>&#160;&#160;&#160; } <\/p>\n<p>#uses the Invoke-Item command to launch the application     <br \/>Invoke-Item &quot;C:\\Program Files\\executable to launch.exe&quot;<\/p>\n<\/blockquote>\n<p>This is for use in a Citrix\/Terminal Server environment, so I want to be able to call this script like this: PowerShell copythenlaunch.ps1<\/p>\n<p>When I tested that, I got this:<\/p>\n<blockquote>\n<p>C:\\IT&gt;powershell copythenlaunch.ps1     <br \/>The term &#8216;copythenlaunch.ps1&#8217; is not recognized as a cmdlet, function, operable      <br \/> program, or script file. Verify the term and try again.      <br \/>At line:1 char:18      <br \/>+ copythenlaunch.ps1 &lt;&lt;&lt;&lt;<\/p>\n<\/blockquote>\n<p>I kept thinking there was some problem with the install of PowerShell (I am running this particular script on a Windows 2003 Server) or that I had some illegal character in the name (it had a number in it originally) or some other simple problem.&#160; Finally I did a search and came across this little bit of conversation:<\/p>\n<blockquote>\n<p>re: Power and Pith<a name=\"1380970\"><\/a><\/p>\n<\/blockquote>\n<blockquote>\n<p>I just started with PowerShell.<\/p>\n<p>Wanted to run some test scripts from you download.<\/p>\n<p>When I tpye in Beep.ps1 I get &quot;The term &#8216;Beep.1&#8217; is not recognized&#8230;..&quot;<\/p>\n<p>What Am I doing wrong?<\/p>\n<p>Friday, December 29, 2006 3:17 PM by <a>MikeL<\/a><\/p>\n<h6><a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/10\/21\/Power-and-Pith.aspx#1381442\">#<\/a> re: Power and Pith<a name=\"1381442\"><\/a><\/h6>\n<p>&gt; When I tpye in Beep.ps1 I get &quot;The term &#8216;Beep.1&#8217; is not recognized&#8230;..&quot;<\/p>\n<p>&gt; What Am I doing wrong?<\/p>\n<p>You are relying upon a traditional bad shell behaviour that has been a security nightmere for decades.<\/p>\n<p>In PowerShell, you have to be explicit if you want to run a command in the current directory.&#160; Type &quot;.\\beep.ps1&quot;<\/p>\n<p>Jeffrey Snover [MSFT]<\/p>\n<p>Windows PowerShell\/MMC Architect<\/p>\n<p>Visit the Windows PowerShell Team blog at:&#160;&#160;&#160; <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><\/p>\n<p>Visit the Windows PowerShell ScriptCenter at:&#160; <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a><\/p>\n<p>Friday, December 29, 2006 5:19 PM by <a href=\"http:\/\/blogs.msdn.com\/user\/Profile.aspx?UserID=29278\">PowerShellTeam<\/a><\/p>\n<h6><a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/10\/21\/Power-and-Pith.aspx#1865770\">#<\/a> re: Power and Pith<a name=\"1865770\"><\/a><\/h6>\n<p><strong>Thank You for supplying the &quot;.\\*&quot; information.&#160; I have been racking my brain for almost two days wondering what I was doing wrong.&#160; And to think it was as simple as using the PROPER .\\yourscripthere.ps1 format.<\/strong><\/p>\n<p>Thank you very very much<\/p>\n<\/blockquote>\n<p>Ditto on the thanks\u2026<\/p>\n<p><a href=\"http:\/\/blogs.msdn.com\/powershell\/archive\/2006\/10\/21\/Power-and-Pith.aspx\">Windows PowerShell Blog : Power and Pith<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been working on a simple little script to copy a file and then launch a program.&#160; I am sure that there are a lot of ways to do it, but I decided to use PowerShell, and this is what I came up with: $CheckForFile = &quot;H:\\custom.ini&quot; $FileToCopy = &quot;c:\\IT\\custom.ini&quot; $CopyFileTo = &quot;H:\\&quot; $PathTest&hellip; <a class=\"more-link\" href=\"https:\/\/blog.nukeitmike.com\/index.php\/2010\/03\/25\/not-recognized-as-a-cmdlet\/\">Continue reading <span class=\"screen-reader-text\">Not recognized as a cmdlet\u2026<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[17,25],"tags":[135,154],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-scripting","tag-powershell","tag-scripting","entry"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pcW544-3U","_links":{"self":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/comments?post=242"}],"version-history":[{"count":0,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/posts\/242\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/media?parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/categories?post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nukeitmike.com\/index.php\/wp-json\/wp\/v2\/tags?post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}