{"id":936,"date":"2010-01-31T11:34:03","date_gmt":"2010-01-31T09:34:03","guid":{"rendered":"https:\/\/www.networknet.nl\/apps\/wp\/archives\/936"},"modified":"2011-11-15T16:47:44","modified_gmt":"2011-11-15T15:47:44","slug":"powershell-how-to-check-list-of-computers-for-a-specific-remote-file","status":"publish","type":"post","link":"https:\/\/www.networknet.nl\/apps\/wp\/archives\/936","title":{"rendered":"PowerShell: How to check list of computers for a specific remote file ?"},"content":{"rendered":"<p>The following PowerShell script recipe will help you check a remote file based on a list of computers stored in a text file. During the session a PowerShell function will be created which will be piped into the text file with computers.<\/p>\n<p>In the following PowerShell example I will check if install.exe exists on the remote systems and echo the computername if the file is there.<\/p>\n<p>Create new text file named C:\\Scripts\\Active_Computers.txt and populate the file with computer names.<\/p>\n<pre class=\"brush:powershell\">function check-remotefile {\r\n\r\n\u00a0\u00a0\u00a0 PROCESS {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $file = \"\\\\$_\\c$\\install.exe\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (test-path $file)\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo \"$_ file install.exe exists\"\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\r\n}\r\n\r\nGet-Content\u00a0 C:\\Scripts\\Active_Computers.txt | check-remotefile<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following PowerShell script recipe will help you check a remote file based on a list of computers stored in a text file. During the session a PowerShell function will be created which will be piped into the text file with computers. In the following PowerShell example I will check if install.exe exists on the remote systems and echo the computername if the file is there. Create new text file named C:\\Scripts\\Active_Computers.txt and populate the file with computer names. function check-remotefile { \u00a0\u00a0\u00a0 PROCESS { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $file = &#8220;\\\\$_\\c$\\install.exe&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (test-path $file) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;$_ file install.exe exists&#8221; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } } Get-Content\u00a0 C:\\Scripts\\Active_Computers.txt | check-remotefile<\/p>\n","protected":false},"author":2,"featured_media":1270,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[515],"tags":[562,254,42,564,561,563],"class_list":["post-936","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell-microsoft","tag-check","tag-file","tag-powershell","tag-remote","tag-test-path","tag-text"],"_links":{"self":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/comments?post=936"}],"version-history":[{"count":11,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/936\/revisions"}],"predecessor-version":[{"id":2070,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/posts\/936\/revisions\/2070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/media\/1270"}],"wp:attachment":[{"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/media?parent=936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/categories?post=936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.networknet.nl\/apps\/wp\/wp-json\/wp\/v2\/tags?post=936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}