SQL Clone 3

Help for older versions available.

Create 'n' clones for an image

This script will create as many clone databases as requested on a given agent.

  1. #Create ā€˜n’ clones from image;
  2. Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
  3.  
  4. $myLocalAgent = "wks-dev1"
  5. $myLocalInstance = "Dev"
  6.  
  7.  
  8. $sqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName $myLocalAgent -InstanceName $myLocalInstance
  9. $image = Get-SqlCloneImage -Name 'StackOverflow Jan 2017'
  10. $ClonePrefix = '_SO_Clone'
  11. $Count = 5 # or however many you want
  12. $elapsed = [System.Diagnostics.Stopwatch]::StartNew()
  13. "Started at {0}" -f $(get-date)
  14. "OK, going to create {0} clones" -f $Count
  15.  
  16. for ($i=0;$i -lt $Count;$i++)
  17. {
  18. $image | New-SqlClone -Name $ClonePrefix$i -Location $sqlServerInstance | Wait-SqlCloneOperation
  19. "Created clone {0}" -f $i;
  20. };
  21. "Total Elapsed Time: {0}" -f $($elapsed.Elapsed.ToString())
  22.  

Didn't find what you were looking for?