<?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: New-NcVolClone suggestions for DR Recovery Script in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111705#M4557</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see the variable dr_vol being defined anywhere (assuming you've posted the entire script). That is the reason you're getting the "Can not bind" error - $dr_vol is in fact null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as getting the cloneVol names in the for-each loop, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_clonevol in $dr_sm_volumes) {
     New-NcVolClone -CloneVolume $dr_clonevol.Name -VserverContext $dr_vs0 -ParentVolume $dr_vol -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;But from your problem description, I think you want the output of Get-NcVol to be the &lt;EM&gt;parent volumes&lt;/EM&gt; and create a clone as parent_vol_name_clone or something similar? In that case, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_vol in $dr_sm_volumes) {
     $dr_clonevol_name = $dr_vol.Name + "_clone";
     New-NcVolClone -CloneVolume $dr_clonevol_name -VserverContext $dr_vs0 -ParentVolume $dr_vol.Name -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Aparajita&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2015 06:01:47 GMT</pubDate>
    <dc:creator>Aparajita</dc:creator>
    <dc:date>2015-10-26T06:01:47Z</dc:date>
    <item>
      <title>New-NcVolClone suggestions for DR Recovery Script</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111689#M4556</link>
      <description>&lt;P&gt;I have to preface this by saying I'm new to powershell. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Criteria:&lt;/P&gt;&lt;P&gt;I want to create a DR Recovery script that will flexclone snapmirrored volumes in our DR Controller based on the VolumeMirrorAttributes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;$dr_vs0 = "net01"&lt;BR /&gt;$dr_vs1 = "net02"&lt;BR /&gt;$cluster = "net"&lt;BR /&gt;Connect-NcController $cluster -Vserver $dr_vs0&lt;BR /&gt;###################################&lt;BR /&gt;###################################&lt;/P&gt;&lt;P&gt;$dr_Attributes = Get-NcVol -VserverContext $dr_vs0 -Template&lt;BR /&gt;$dr_Query = Get-NcVol -Template&lt;BR /&gt;Initialize-NcObjectProperty -object $dr_Query -name VolumeMirrorAttributes&lt;BR /&gt;$dr_Query.VolumeMirrorAttributes.IsDataProtectionMirror = "True"&lt;BR /&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query&lt;/P&gt;&lt;P&gt;$dr_clonevol = $dr_sm_volumes | Select-Object Name | ForEach-Object {$_.Name}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ForEach ($dr_i in $dr_clonevol) {&lt;/P&gt;&lt;P&gt;New-NcVolClone -CloneVolume $dr_vol"" -VserverContext $dr_vs0 -ParentVolume $dr_vol -SpaceReserve none&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I pass the variable "&lt;SPAN&gt;$dr_clonevol" in to the ForEach loop and use it to name the cloned volume in the -CloneVolume parameter?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I keep getting "New-NcVolClone : Cannot bind argument to parameter 'ParentVolume' because it is null."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;echo $dr_clonevol&lt;BR /&gt;vs1_data_xpd_2hr_01_mirror&lt;BR /&gt;vs1_data_xpd_2hr_04_mirror&lt;BR /&gt;vs1_data_xpd_2hr_05_mirror&lt;BR /&gt;vs1_vs1_data_xpd_2hr_02_mirror&lt;BR /&gt;vs1_vs1_data_xpd_2hr_03_mirror&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!!!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 22:58:14 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111689#M4556</guid>
      <dc:creator>bthurber</dc:creator>
      <dc:date>2025-06-04T22:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: New-NcVolClone suggestions for DR Recovery Script</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111705#M4557</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see the variable dr_vol being defined anywhere (assuming you've posted the entire script). That is the reason you're getting the "Can not bind" error - $dr_vol is in fact null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as getting the cloneVol names in the for-each loop, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_clonevol in $dr_sm_volumes) {
     New-NcVolClone -CloneVolume $dr_clonevol.Name -VserverContext $dr_vs0 -ParentVolume $dr_vol -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;But from your problem description, I think you want the output of Get-NcVol to be the &lt;EM&gt;parent volumes&lt;/EM&gt; and create a clone as parent_vol_name_clone or something similar? In that case, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_vol in $dr_sm_volumes) {
     $dr_clonevol_name = $dr_vol.Name + "_clone";
     New-NcVolClone -CloneVolume $dr_clonevol_name -VserverContext $dr_vs0 -ParentVolume $dr_vol.Name -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Aparajita&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 06:01:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111705#M4557</guid>
      <dc:creator>Aparajita</dc:creator>
      <dc:date>2015-10-26T06:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: New-NcVolClone suggestions for DR Recovery Script</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111764#M4558</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/24143"&gt;@Aparajita&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see the variable dr_vol being defined anywhere (assuming you've posted the entire script). That is the reason you're getting the "Can not bind" error - $dr_vol is in fact null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as getting the cloneVol names in the for-each loop, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_clonevol in $dr_sm_volumes) {
     New-NcVolClone -CloneVolume $dr_clonevol.Name -VserverContext $dr_vs0 -ParentVolume $dr_vol -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;But from your problem description, I think you want the output of Get-NcVol to be the &lt;EM&gt;parent volumes&lt;/EM&gt; and create a clone as parent_vol_name_clone or something similar? In that case, I would suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query

ForEach ($dr_vol in $dr_sm_volumes) {
     $dr_clonevol_name = $dr_vol.Name + "_clone";
     New-NcVolClone -CloneVolume $dr_clonevol_name -VserverContext $dr_vs0 -ParentVolume $dr_vol.Name -SpaceReserve none 
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Aparajita&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I didn't include the intire script, only the final "at wits end" attempt but you obviously got the gist of what I was attempting to do. &amp;nbsp;I ran with your recommendation and got the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;New-NcVolClone : Clone of a DP volume vs1_data_xpd_2hr_01_mirror cannot be created without snapshot. Please provide snapshot&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;I made the following modification:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ForEach ($dr_vol in $dr_sm_volumes) {
     
     $getsnap = Get-NcSnapshot -Volume $dr_vol.Name | sort Created -Descending
     $getsnap_snap0 = $getsnap[0]
     
     $dr_clonevol_name = $dr_vol.Name + "_DR_Test";
     New-NcVolClone -CloneVolume $dr_clonevol_name -VserverContext $dr_vs0 -ParentVolume $dr_vol.Name -SpaceReserve none -ParentSnapshot $getsnap_snap0
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This worked perfectly... the takeaway being the .Name after the variable. &amp;nbsp;I don't understand why it's required - is this something you learn as you go?&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://community.netapp.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2015 00:12:40 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111764#M4558</guid>
      <dc:creator>BradT</dc:creator>
      <dc:date>2015-10-27T00:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: New-NcVolClone suggestions for DR Recovery Script</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111766#M4559</link>
      <description>It's pretty intuitive once you get used to "everything is an object, or should be" philosophy of PowerShell (takes a while if you're used to a *nix shell).&lt;BR /&gt;&lt;BR /&gt;The output of Get-NcVol is an array of objects. So $dr_vol inside the foreach is an object. But the ParentVolume parameter of New-NcClone doesn't take a volume object, only a string value for the name. Hence the .Name to dereference the proper attribute of the $dr_vol object.</description>
      <pubDate>Tue, 27 Oct 2015 00:48:13 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/New-NcVolClone-suggestions-for-DR-Recovery-Script/m-p/111766#M4559</guid>
      <dc:creator>Aparajita</dc:creator>
      <dc:date>2015-10-27T00:48:13Z</dc:date>
    </item>
  </channel>
</rss>

