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.
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.
Tagged:
Best Answer
-
ErdoganOzkoca Posts: 19 Bronze 3Hi,
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-SqlCloneSqlServerInstanceforeach($instance IN $sqlServerInstances){if($instance.Id -eq $cloneLocationId){Write-Output $instance}}
Answers
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