Provisioning sanitized data with SQL Clone and Data Masker. Watch now.

How to get clone location from Get-SqlClone

RyanHRyanH Posts: 2 New member
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.

Best Answer

  • ErdoganOzkocaErdoganOzkoca Posts: 19 Bronze 3

    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


  • RyanHRyanH Posts: 2 New member
    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

Sign In or Register to comment.