SQL Clone 4

Cannot convert 'System.Object[]' to the type '...' required by parameter '...'. Specified method is not supported.

The error means that a collection of objects is passed as a parameter to a Powershell commmand that expects a single object as the parameter.

Let's take the following script as an example:

$image = Get-SqlCloneImage
$clones = Get-SqlClone -Image $image

If there are multiple images the second line will fail with
Get-SqlClone : Cannot convert 'System.Object[]' to the type 'RedGate.SqlClone.Client.Api.Objects.ImageResource' required by parameter 'Image'. Specified method is not supported.
because Get-SqlCloneImage returns a collection of all existing images and Get-SqlClone expects a single image to be passed as its Image parameter.

However, if there's only one image in SQL Clone then GetSqlClone -Image $image is able to interpret the collection containing this single image as a single object and the script will work.

That means that a script may work intially, but fail with Cannot convert 'System.Object[]' to the type '...' required by parameter '...'. error when more images, clones or instances are created or added.

To fix the error you need to specify additional parameters to narrow down the result of a Get- command to a single object:

$image = Get-SqlCloneImage -Name 'StackOverflow Jan 2017'
$clones = Get-SqlClone -Image $image

To avoid the error appearing when more resources are created or added you should assume that any Get- method without parameters can return a collection of several objects. Documentation for each specific command describes which values are returned based on the provided parameters.


Didn't find what you were looking for?