Can you retrieve the Image Name from a clone

Hi,

I have some custom PowerShell that deletes and recreates clones on deployments, but due to the size of some of these, I only want to do this if the latest image has changed from the image that was used for the existing clone. If the same image was already used to created the clone then I just want to reset the clone. This is important to reduce the pipeline deployment times.

I don't seem to be able to get the Image from a clone resource object (RedGate.SqlClone.Client.Api.Objects.CloneResource)

$SqlServerInstance = Get-SqlCloneSqlServerInstance -MachineName "MyServer" -InstanceName ""
$currentClone = Get-SqlClone -Name 'MyDatabase' -Location $SqlServerInstance

Here I would like to be able to use $currentClone.Image.Name or something similar, but I can't see how. I see an option for $currentClone.ParentImageId, however I can't call Get-SqlCloneImage with an Id - I need the name, which is what I'm looking for.

Any ideas for getting the image name from a clone resource?

Tagged:

Best Answer

  • Tianjiao_LiTianjiao_Li Posts: 684 Rose Gold 5
    @JohnnyC3PO

    It looks like there's currently no way to get an image by ID directly using the cmdlets.

    So, probably the simplest option for now is:

    $myClone = Get-SqlClone 'MyClone'
    $myCloneImage = Get-SqlCloneImage | Where-Object { $_.Id -eq $myClone.ParentImageId }
    Kind regards

    Tianjiao Li | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.