<?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 Re: Script for creating vols/qtrees from hostname in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29794#M1353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Certainly!&amp;nbsp; You're pretty good on the structure too.&amp;nbsp; In case you need some help with the syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Import-Module dataontap&lt;/P&gt;&lt;P&gt;$hosts = "foo","bar","baz"&lt;/P&gt;&lt;P&gt;Connect-NaController 10.61.169.28&lt;/P&gt;&lt;P&gt;$hosts | foreach {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-NaVol "$($_)_boot" -Aggregate aggr0 -SpaceReserve none -Size 10g&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-NaQtree "/vol/$($_)_boot/$($_)_boot.q"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another tip, if you aren't sure what a cmdlet will do, most cmdlets (in the toolkit or otherwise) support the "-WhatIf" switch which will show you the operation it will perform, but won't actually do anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Oct 2011 12:40:17 GMT</pubDate>
    <dc:creator>timothyn</dc:creator>
    <dc:date>2011-10-18T12:40:17Z</dc:date>
    <item>
      <title>Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29785#M1351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to build a script which can create FlexVols and qtrees from a list of hostnames. The names of the vols and the qtrees will be based on the hostnames of the servers which will connect to the LUNs contained within the qtrees.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you able to give me some pointers on where I should start please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 06:43:32 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29785#M1351</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2025-06-05T06:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29789#M1352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would something like this work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;# Define Hostnames&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $host1 = computer1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $host2 = computer2&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $host3 = computer3&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $hosts = $host1, $host2, $host3&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Load the DataONTAP Module&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Import-Module DataONTAP&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Connect to the filer&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Connect-NaController filer1&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create FlexVol&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $hosts : ForEach-Object &amp;lt; New-NaVol -Name "$hosts_BOOT" -Aggregate aggr_test -SpaceReserve none&amp;nbsp; -Size 100g &amp;gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;EM&gt;# Create Qtree&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $hosts : ForEach-Object &amp;lt; New-NaQtree "/vol/$hosts_BOOT/$hosts_boot.q"&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 00:53:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29789#M1352</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2011-10-18T00:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29794#M1353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Certainly!&amp;nbsp; You're pretty good on the structure too.&amp;nbsp; In case you need some help with the syntax:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;Import-Module dataontap&lt;/P&gt;&lt;P&gt;$hosts = "foo","bar","baz"&lt;/P&gt;&lt;P&gt;Connect-NaController 10.61.169.28&lt;/P&gt;&lt;P&gt;$hosts | foreach {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-NaVol "$($_)_boot" -Aggregate aggr0 -SpaceReserve none -Size 10g&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; New-NaQtree "/vol/$($_)_boot/$($_)_boot.q"&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another tip, if you aren't sure what a cmdlet will do, most cmdlets (in the toolkit or otherwise) support the "-WhatIf" switch which will show you the operation it will perform, but won't actually do anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 12:40:17 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29794#M1353</guid>
      <dc:creator>timothyn</dc:creator>
      <dc:date>2011-10-18T12:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29803#M1354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Eric, really appreciate the reply and pleased I wasn't too wide of the mark.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Will the commands be run in order? For example, after the 'foo_boot' volume has been created, will the 'foo_boot.q' qtree be created inside it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. How does the '$($_)' part of the script work? I was thinking I'd have to put in the '$hosts' variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the '-WhatIf' tip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 12:57:31 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29803#M1354</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2011-10-18T12:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29808#M1355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, there is some PowerShell magic there.&amp;nbsp; &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"$hosts | foreach" pipes the list of hostnames to a loop of commands, each time that loop executes it stores the current item (hostname) in the "$_" variable.&amp;nbsp; &lt;UL&gt;&lt;LI&gt;"$_" is pretty important in PowerShell, you an learn more about it by running &lt;EM&gt;help about_Automatic_Variables&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Inside the foreach loop (really a block), the commands are always executed in order&lt;/LI&gt;&lt;LI&gt;PowerShell automatically does string substitution on doubly quoted strings, see &lt;EM&gt;help about_quoting_rules&lt;/EM&gt; for details&lt;UL&gt;&lt;LI&gt;"$_ boot" would automatically work, but PowerShell gets confused by the extra underscore in "$__boot" and doesn't know where the variable ends.&lt;/LI&gt;&lt;LI&gt;"$()" will evaluate any expression inside it without worrying about the text around it&lt;/LI&gt;&lt;LI&gt;"$($_)" evaluates the $_ variable, in this case the current item from the list of hostnames&lt;/LI&gt;&lt;LI&gt;"$($_)_boot" evaluates to something like "foo_boot"&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 13:19:04 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29808#M1355</guid>
      <dc:creator>timothyn</dc:creator>
      <dc:date>2011-10-18T13:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29817#M1357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eric,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's brilliant, thanks very much for your help and I appreciate the time you've given to answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Ty&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 19:23:55 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29817#M1357</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2011-10-18T19:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29822#M1359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;......another thought, if I wanted to read in the list of hosts from a text file as opposed to defining a list within the script, can I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got the hosts listed in an Excel spreadsheet I'm thinking if I can export this out to a text file and read it into the script it would save my typing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 12:42:11 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29822#M1359</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2011-10-19T12:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29825#M1361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of course!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-Content works great for a simple file with one item per line:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;PS C:\&amp;gt; $hosts = get-content C:\temp\hosts.txt&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if you have more sophisticated data, Import-Csv can read CSV files (easily exported from Excel).&amp;nbsp; "help Get-Content" or "help Import-Csv" will tell you more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 14:14:29 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29825#M1361</guid>
      <dc:creator>timothyn</dc:creator>
      <dc:date>2011-10-19T14:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script for creating vols/qtrees from hostname</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29834#M1364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks once again Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 09:47:40 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Script-for-creating-vols-qtrees-from-hostname/m-p/29834#M1364</guid>
      <dc:creator>tyrone_owen_1</dc:creator>
      <dc:date>2011-10-21T09:47:40Z</dc:date>
    </item>
  </channel>
</rss>

