How can we help you today? How can we help you today?

Is there a way to identify the oldest version of an image, based on the original database name?

Hi Guys,

I am trying to accomplish the following via PowerShell.

In my enviroment I have multiple images of multiple databases (each Image has a different name).

I am looking for a method to easily identify the oldest version of each database images (using "OriginDatabaseName" in the Get-SqlCloneImage cmdlet to identify the original database). I have tried to identify these by using Get-SqlCloneImage, but I am having difficulty formulating the right approach.

I have hit a brick wall with this - my powershell skills are getting better, but I am not an expert. Any help with this would be greatly appreciated.

Thanks,




RedgateRoss
0

Comments

2 comments

  • chris_godfree

    Hi RedgateRoss, here's some Powershell I use to find the most recent image for any given database:

    $allImages = Get-SqlCloneImage | Where-Object {$_.OriginDatabaseName -eq $database}

    $LatestImage = $allImages | Sort-Object -Property CreatedDate | Select-Object -Last 1

    $latestImageName = $latestImage.Name

    Chris


    chris_godfree
    0
  • RedgateRoss
    Thank you, Chris.

    A much more elgant mehtod than the one i came up with!

    I'm really impressed with the knowledge on these forums.

    Thanks again,
    Ross
    RedgateRoss
    0

Add comment

Please sign in to leave a comment.