SQL Clone 5

New-SqlClone

Starts creating a clone from an image.

Syntax

New-SqlClone [-Image] <ImageResource> [-Name] <string> [-Location] <SqlServerInstanceResource> [-OverrideStorageLocation <string>] [-Template <psobject>] [<CommonParameters>]

Description

The New-SqlClone cmdlet starts creating a clone from an image and outputs details of the creation operation.

This cmdlet returns a OperationResource which can be passed to the Wait-SqlCloneOperation cmdlet.

Connect-SqlClone must be called before this cmdlet.

Parameters

-Image <RedGate.SqlClone.Client.Api.Objects.ImageResource>

Specifies the parent image that will be cloned. The Get-SqlCloneImage cmdlet can be used to get an ImageResource.

Aliases None
Required? true
Position? 0
Default Value None
Accept Pipeline Input true (ByValue)
Accept Wildcard Characters false

-Name <System.String>

Specifies the database name of the clone. This needs to be a unique database name within the specified SQL Server instance. This value has a maximum length of 128 characters.

Aliases None
Required? true
Position? 1
Default Value None
Accept Pipeline Input false
Accept Wildcard Characters false

-Location <RedGate.SqlClone.Client.Api.Objects.SqlServerInstanceResource>

Specifies the SQL Server instance that the clone will be created on. The Get-SqlCloneSqlServerInstance cmdlet can be used to get a SqlServerInstanceResource.

Aliases None
Required? true
Position? 2
Default Value None
Accept Pipeline Input false
Accept Wildcard Characters false

-OverrideStorageLocation <System.String>

Specifies where the clone data files will be physically stored on disk. This path is relative to the machine on which the clone is being created.

Aliases None
Required? false
Position? named
Default Value None
Accept Pipeline Input false
Accept Wildcard Characters false

-Template <System.Management.Automation.PSObject>

Specifies the clone template that will be run during clone creation (check the parent image to see what templates are available). Accepts a CloneTemplateResource (obtained using the Get-SqlCloneTemplate cmdlet) or a string (the template's name).

Aliases None
Required? false
Position? named
Default Value None
Accept Pipeline Input false
Accept Wildcard Characters false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see http://technet.microsoft.com/en-us/library/hh847884.aspx.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • RedGate.SqlClone.Client.Api.Objects.ImageResource

    Specifies the parent image that will be cloned. The Get-SqlCloneImage cmdlet can be used to get an ImageResource.

Return values

The output type is the type of the objects that the cmdlet emits.

  • RedGate.SqlClone.Client.Api.Objects.OperationResource

Examples

---------- EXAMPLE 1 ----------

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$Image = Get-SqlCloneImage -Name 'AdventureWorks-20170106110745'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
New-SqlClone -Name 'AdventureWorks-clone1' -Location $SqlServerInstance -Image $Image

This example starts creating a new clone named 'AdventureWorks-clone1' on WIN201601\SQL2014 based on the image named 'AdventureWorks-20170106110745'.

---------- EXAMPLE 2 ----------

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$Image = Get-SqlCloneImage -Name 'AdventureWorks-20170106110745'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
$Image | New-SqlClone -Name 'AdventureWorks-clone1' -Location $SqlServerInstance | Wait-SqlCloneOperation

This example uses the pipeline operator to create a new clone and waits for the creation to complete before returning.

---------- EXAMPLE 3 ----------

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$Image = Get-SqlCloneImage -Name 'AdventureWorks-20170106110745'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
New-SqlClone -Name 'AdventureWorks-clone1' -Location $SqlServerInstance -Image $Image -OverrideStorageLocation 'D:\Clones'

This example creates a clone in the same way as example 1, but stores its files in a specified location. The supplied path is relative to the machine on which the clone is being created.

---------- EXAMPLE 4 ----------

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$Image = Get-SqlCloneImage -Name 'AdventureWorks-20170106110745'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
$Template = Get-SqlCloneTemplate -Image $Image -Name "modificationTemplate1"
New-SqlClone -Name 'AdventureWorks-clone1' -Location $SqlServerInstance -Image $Image -Template $Template

This example creates a clone in the same way as example 1 and modificationTemplate1 is run during clone creation.

---------- EXAMPLE 5 ----------

Connect-SqlClone -ServerUrl 'http://sql-clone.example.com:14145'
$Image = Get-SqlCloneImage -Name 'AdventureWorks-20170106110745'
$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName WIN201601 -InstanceName SQL2014
New-SqlClone -Name 'AdventureWorks-clone1' -Location $SqlServerInstance -Image $Image -Template "modificationTemplate1"

This example creates a clone in the same way as example 1 and modificationTemplate1 is run during clone creation.


Didn't find what you were looking for?