Hi everyone,
I've not that new with PowerShell and have been using it for some time but am by no means a Guru.
I have 17 NFS volumes, each containing a VMDK, which is attached to a SQL server. I'm trying to simplify my refresh process to out SQL DEV server. I have been using VMware PowerCLI and NetApp CLI to obtain my results but it's time-consuming..
I’d like to build a script that would:
- Query for the Volumes
- Get-NcVol -Volume ESX_NFS_N*
- Query for the clones
- Dismount and delete the clones
- Query for the latest snapshot
- Create a clone from the latest Snapshot
- Mount junction path
I found a script close to what I was looking for @ https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Getting-the-latest-snapshot-name/td-p/135117
# get all snapmirror destination volumes for the desired SVM
Get-NcSnapmirror -Query @{ DestinationVserver = $svmName; RelationshipType = "data_protection"; } | ForEach-Object {
# cleanup the old clone
$currentClone = Get-NcVolClone -Query @{ Vserver = $svmName; ParentVolume = $_.DestinationVolume } | Get-NcVol
$currentClone | Dismount-NcVol -Confirm:$false | Set-NcVol -Offline -Confirm:$false | Remove-NcVol -Confirm:$false
# get the newest snapshot on the snapmirorr destination volume
$newestSnap = Get-NcVol -Vserver $svmName -Name $_.DestinationVolume | Get-NcSnapshot | Sort-Object -Property Created -Descending | Select-Object -First 1
# create the volume clone
$splat = @{
# the SVM to use for the clone...the same as the source volume
'Vserver' = $svmName;
# the name of the new volume
'CloneVolume' = "$($_.DestinationVolume)_clone";
# the parent SVM
'ParentVserver' = $svmName;
# the source volume
'ParentVolume' = $_.DestinationVolume;
# the source snapshot
'ParentSnapshot' = $newestSnap.Name
# thin provision
'SpaceReserve' = "none";
# junction at the new volume name, not needed if using LUNs
'JunctionPath' = "/$($_.DestinationVolume)_clone"
# make sure it's an active junction, not needed if using LUNs
'JunctionActive' = $true;
}
New-NcVolClone @splat
# not included, making a LUN in the volume available
}
Any help would be greatly appreciated.