VMware Cloud Community
tdubb123
Expert
Expert
Jump to solution

Get-HardDisk : Cannot process argument transformation on parameter 'Datastore'. Strings as pipeline input are not supported.

any idea why I am getting this error?

$VMs = get-content vms.txt

foreach ($VM in $VMs)

{

$VMDK = $VM | get-harddisk }

sk

Get-HardDisk : Cannot process argument transformation on parameter 'Datastore'. Strings as pipeline input are not supported.

At line:1 char:7

+ $VM | Get-HardDisk

+       ~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (xjzxbwg1105x:PSObject) [Get-HardDisk], ParameterBindingArgumentTransformationException

    + FullyQualifiedErrorId : ParameterArgumentTransformationError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetHardDisk

0 Kudos
1 Solution

Accepted Solutions
sajal1
Hot Shot
Hot Shot
Jump to solution

I suppose the content of the file vms.txt has a list of VM Names.

So when you import it in the variable $VMs, it has a list of the VM Names. Similarly $VM has a string value with the name of a VM. So in the "$VMDK = $VM | get-harddisk" you are essentially giving a string value and trying to get the Get-Harddisk of the VM. This is obviously failing as the pipeline input should an object.

Change it to "Get-VM $VM | Get-HardDisk" Should do.

$VMs = get-content vms.txt

foreach ($VM in $VMs)

{

$VMDK = Get-VM $VM | get-harddisk }

View solution in original post

0 Kudos
2 Replies
sajal1
Hot Shot
Hot Shot
Jump to solution

I suppose the content of the file vms.txt has a list of VM Names.

So when you import it in the variable $VMs, it has a list of the VM Names. Similarly $VM has a string value with the name of a VM. So in the "$VMDK = $VM | get-harddisk" you are essentially giving a string value and trying to get the Get-Harddisk of the VM. This is obviously failing as the pipeline input should an object.

Change it to "Get-VM $VM | Get-HardDisk" Should do.

$VMs = get-content vms.txt

foreach ($VM in $VMs)

{

$VMDK = Get-VM $VM | get-harddisk }

0 Kudos
tdubb123
Expert
Expert
Jump to solution

thank you

0 Kudos