<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using Test-Path to check files on filer in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71072#M3506</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know a way to use Test-path to see if a file lives on the filer? I think I someone need to use Read-NaFile, but I cannot quite figure it out. If the file is not there when reading, it throws an error. I would like to surpress the error, but set a variable to false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jun 2025 07:01:19 GMT</pubDate>
    <dc:creator>drwoodberry</dc:creator>
    <dc:date>2025-06-05T07:01:19Z</dc:date>
    <item>
      <title>Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71072#M3506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know a way to use Test-path to see if a file lives on the filer? I think I someone need to use Read-NaFile, but I cannot quite figure it out. If the file is not there when reading, it throws an error. I would like to surpress the error, but set a variable to false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 07:01:19 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71072#M3506</guid>
      <dc:creator>drwoodberry</dc:creator>
      <dc:date>2025-06-05T07:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71075#M3507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use Read-NaFile in a try/catch block to see if a file exists:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt; font-family: courier new,courier; "&gt;PS C:\&amp;gt; try { Read-NaFile /vol/vol0/etc/host -Length 1 -Offset 0 } catch { Write-Host "Not found" }&lt;BR /&gt;Not found&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using Test-Path would require a PowerShell &lt;EM&gt;provider&lt;/EM&gt;, which isn't included in Toolkit 1.2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jan 2011 20:14:29 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71075#M3507</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-01-25T20:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71083#M3508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I guess that is something I would like to see in the toolkit then.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN __jive_emoticon_name="laugh" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon" src="https://community.netapp.com/4.0.8/images/emoticons/laugh.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That process is not quite working for me. If the file is there, I would like to set a variable to true, otherwise to false. I tried it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try{Read-NaFile /vol/vol0/etc/info}&lt;/P&gt;&lt;P&gt;catch{$configured = $false}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No matter what, I get $configured as false when this runs. Maybe I missed something, but I thought that if an exception was thrown, it only then did what was in the catch.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jan 2011 21:38:14 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71083#M3508</guid>
      <dc:creator>drwoodberry</dc:creator>
      <dc:date>2011-01-25T21:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71088#M3509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You still have to set the variable to true if the file is present.&amp;nbsp; This works for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt; font-family: courier new,courier; "&gt;PS C:\&amp;gt; try { Read-NaFile /vol/vol0/etc/hosts -Length 1 -Offset 0 | Out-Null; $configured = $true } catch { $configured = $false }&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 15:15:39 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71088#M3509</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-01-26T15:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71092#M3510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks so much. When I used your first solution to and checked the value of configured it always returned false, but the program ran correctly. I am going to test your second solution shortly as well. Thanks so much for all your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 15:38:05 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71092#M3510</guid>
      <dc:creator>drwoodberry</dc:creator>
      <dc:date>2011-01-26T15:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71097#M3511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use Test-Path if you access the NetApp via CIFS.&amp;nbsp; Below is some code to test for the existence of the file...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# use the net.exe application to connect to &lt;A target="_blank"&gt;\\filer\c$&lt;/A&gt; using specified credentials&lt;/P&gt;&lt;P&gt;C:\Windows\System32\net.exe use &lt;A target="_blank"&gt;\\filer\c$&lt;/A&gt; /user:domain\username password&lt;/P&gt;&lt;P&gt;#test for existence of the hosts file on the NetApp&lt;/P&gt;&lt;P&gt;$result = Test-Path &lt;A target="_blank"&gt;\\filer\c$\etc\hosts&lt;/A&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 19:50:45 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71097#M3511</guid>
      <dc:creator>paleon</dc:creator>
      <dc:date>2011-01-26T19:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71102#M3512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;Using Test-Path would require a PowerShell &lt;EM&gt;provider&lt;/EM&gt;, which isn't included in Toolkit 1.2.&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But Toolkit 1.3 does include a PowerShell provider!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; &lt;SPAN style="color: #0000ff;"&gt;Connect-NaController &lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;lt;name&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; &lt;SPAN style="color: #0000ff;"&gt;Mount-NaController&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; &lt;SPAN style="color: #0000ff;"&gt;Test-Path &lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;lt;name&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;:/etc/host&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000; font-family: courier new,courier; "&gt;False&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; &lt;SPAN style="color: #0000ff;"&gt;Test-Path &lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&amp;lt;name&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;:/etc/hosts&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt; &lt;SPAN style="color: #ff0000;"&gt;True&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jan 2011 22:11:53 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71102#M3512</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-01-31T22:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71106#M3513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did not see tool kit 1.3. Is the available to the general public. I like the try catch method, but this mount cmdlet is nice. I have used the try,catch for other error checking and has proven invaluable. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 16:55:04 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71106#M3513</guid>
      <dc:creator>drwoodberry</dc:creator>
      <dc:date>2011-02-04T16:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Test-Path to check files on filer</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71111#M3514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, Toolkit 1.3 is available on the &lt;A _jive_internal="true" href="https://community.netapp.com/community/interfaces_and_tools/data_ontap_powershell_toolkit/data_ontap_powershell_toolkit_downloads" target="_blank"&gt;downloads&lt;/A&gt; page; it merely replaces the older zip file.&amp;nbsp; You must be logged into the community with a NOW login ID to see that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 17:46:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Test-Path-to-check-files-on-filer/m-p/71111#M3514</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-02-04T17:46:47Z</dc:date>
    </item>
  </channel>
</rss>

