The installer automatically sets up PowerShell to use the module located at: C:\Program Files (x86)\Red Gate\Instant Clone X.Y.Z\Modules\. Run the PowerShell command-line or ISE as an administrator. Use the cmdlets like this. Finish all invocations with –Verbose to see debug output.
# Set connection string for use by Instant Clone. Only need to do this the first time
Initialize-InstantCloneConnectionString -ConnectionString "Server=JOHNSMITHTEST\sql2012;Trusted_Connection=True" -Verbose
# Save a snapshot of my WidgetProd database to disk
Save-InstantCloneSnapshot -DatabaseName WidgetProd -SnapshotName WidgetSnp1 -Verbose
# Create a couple of clones from the WidgetSnp1 snapshot
New-InstantCloneClone -NewDatabaseName WidgetClone1 -SnapshotName WidgetSnp1 -Verbose
New-InstantCloneClone -NewDatabaseName WidgetClone2 -SnapshotName WidgetSnp1 -Verbose
# I'm bored with these clones now. Let's drop them
Remove-InstantCloneClone -CloneName WidgetClone1 -Verbose
Remove-InstantCloneClone -CloneName WidgetClone2 -Verbose
# Let's drop that snapshot too
Remove-InstantCloneSnapshot -SnapshotName WidgetSnp1 -Verbose
When you restart your machine, clone databases will be offline until you run the restore cmdlet:
Restore-InstantClone -Verbose
See all the clones and snapshots with the Show-InstantCloneSnapshots/Clones cmdlets
Show-InstantCloneSnapshots -Verbose
Show-InstantCloneClones -Verbose
See all cmdlets available with the Get-Command cmdlet:
Get-Command -Module RedGate.InstantClone.PowerShell
You may want to create a snapshot on one machine, but clone it on another. To do this, setup the
On the source machine:
Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose
Save-InstantCloneSnapshot -DatabaseName AdventureWorks -SnapshotName AdvSnap -Verbose
Save-InstantCloneSharedSnapshot -SnapshotName AdvSnap -NewSnapshotName AdvSnapShared
A shared-snapshot can listed/deleted/cloned just like any other snapshot.
On the target machine:
Save-InstantCloneOptions -SharedSnapshotFolder [\\myServer\SharedSnapshots|\\myServer\SharedSnapshots] -Verbose
Show-InstantCloneSnapshots -Verbose
New-InstantCloneClone -SnapshotName AdvSnapShared -NewDatabaseName AdvClone -Verbose