I have to preface this by saying I'm new to powershell.
Criteria:
I want to create a DR Recovery script that will flexclone snapmirrored volumes in our DR Controller based on the VolumeMirrorAttributes.
Script:
$dr_vs0 = "net01"
$dr_vs1 = "net02"
$cluster = "net"
Connect-NcController $cluster -Vserver $dr_vs0
###################################
###################################
$dr_Attributes = Get-NcVol -VserverContext $dr_vs0 -Template
$dr_Query = Get-NcVol -Template
Initialize-NcObjectProperty -object $dr_Query -name VolumeMirrorAttributes
$dr_Query.VolumeMirrorAttributes.IsDataProtectionMirror = "True"
$dr_sm_volumes = Get-NcVol -Attributes $dr_Attributes -Query $dr_Query
$dr_clonevol = $dr_sm_volumes | Select-Object Name | ForEach-Object {$_.Name}
ForEach ($dr_i in $dr_clonevol) {
New-NcVolClone -CloneVolume $dr_vol"" -VserverContext $dr_vs0 -ParentVolume $dr_vol -SpaceReserve none
}
How would I pass the variable "$dr_clonevol" in to the ForEach loop and use it to name the cloned volume in the -CloneVolume parameter?
I keep getting "New-NcVolClone : Cannot bind argument to parameter 'ParentVolume' because it is null."
echo $dr_clonevol
vs1_data_xpd_2hr_01_mirror
vs1_data_xpd_2hr_04_mirror
vs1_data_xpd_2hr_05_mirror
vs1_vs1_data_xpd_2hr_02_mirror
vs1_vs1_data_xpd_2hr_03_mirror
Thanks in advance!!!