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,
Comments
2 comments
-
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
-
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
Add comment
Please sign in to leave a comment.