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

How to get clone location from Get-SqlClone

Is there any way to identify which server a clone sits on using the PowerShell cmdlets?
I was expecting Get-SqlClone to return the server name. I can't currently see any way of tying the outputs of Get-SqlClone and Get-SqlCloneSqlServerInstance together.
Ryan
0

Comments

2 comments

  • ErdoganOzkoca
    Hi,

    When you run Get-SqlClone, cmdlet returns you a CloneResource object which includes LocationId. But the problem is, it is not possible to get the SqlServerInstance by using this LocationId. A basic solution is, you can query all Sql Server Instances by using Get-SqlCloneSqlServerInstance and you can try to find the LocationId in the result of Get-SqlCloneSqlServerInstance. You can find an example query below.

    Connect-SqlClone -ServerUrl 'http://your_sql_clone_server_url'
    $clone = Get-SqlClone -Name 'your_clone_name'
    $cloneLocationId = $clone.LocationId
    $sqlServerInstances = Get-SqlCloneSqlServerInstance
    foreach($instance IN $sqlServerInstances)
    {
       if($instance.Id -eq $cloneLocationId)
       {
          Write-Output $instance
       }
    }
    ErdoganOzkoca
    0
  • RyanH
    That does the job nicely, thanks.
    I'd seen the location id but hadn't put it together that that was the id of the server.

    It would be handy as a future improvement if both Get-SqlClone and Get-SqlCloneSqlServerInstance both returned the LocationId property

    RyanH
    0

Add comment

Please sign in to leave a comment.