Good morning All!
I'm having some troubles in order to attach an existing vmdk file ( which is not being used in any other vm ), into a new vm that doesn't have any disks drives on it, using powercli.
I'm trying to use the New-HardDisk cmdlet but I'm encountering the following errors:
If I try to get the disks from a specific file path. I see the following output ( I do get the disks thou ):
PowerCLI C:\> Get-HardDisk -Datastore "DATA2-Test"
CapacityGB Persistence Filename
---------- ----------- --------
500.000 Unknown ...A2-Test] DATA2-W2k16/DATA2-W2k16_1.vmdk
200.000 Unknown [DATA2-Test] DATA2-W2k16/DATA2-W2k16.vmdk
Get-HardDisk : 6/11/2019 7:01:43 AM Get-HardDisk File [DATA2-Test] was not found
At line:1 char:1
+ Get-HardDisk -Datastore DATA2-Test"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HardDisk], FileNotFound
+ FullyQualifiedErrorId : Client20_DatastoreServiceImpl_ExecuteDatastoreSearch_ViError,VMware.VimAutomation.ViCore
.Cmdlets.Commands.VirtualDevice.GetHardDisk
If I try to get a specific disk, the cmdlet returns it, but it gaves me an error as well:
PowerCLI C:\> $disk0 = Get-HardDisk -Datastore "DATA2-Test" -DatastorePath "[DATA2-Test] DATA2-W2k16/DATA2-W2k16.vmdk"
Get-HardDisk : 6/11/2019 7:13:00 AM Get-HardDisk File [DATA2-Test] was not found
At line:1 char:10
+ $disk0 = Get-HardDisk -Datastore "DATA2-Test" -DatastorePath "[DATA2-Test] DAT ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-HardDisk], FileNotFound
+ FullyQualifiedErrorId : Client20_DatastoreServiceImpl_ExecuteDatastoreSearch_ViError,VMware.VimAutomation.ViCore
.Cmdlets.Commands.VirtualDevice.GetHardDisk
When I check the variable, I do see the disk:
PowerCLI C:\> $disk0
CapacityGB Persistence Filename
---------- ----------- --------
200.000 Unknown [DATA2-Test] DATA2-W2k16/DATA2-W2k16.vmdk
PowerCLI C:\> $disk0.Filename
[DATA2-Test] DATA2-AH-W2k16/DATA2-W2k16.vmdk
However, even if I ignore the error, I'm having troubles to assign it to a new vm:
PowerCLI C:\> $vm = Get-VM DATA2-AH-W2k16-Test
PowerCLI C:\> New-HardDisk -vm $vm -DiskPath $disk0.Filename
New-HardDisk : 6/11/2019 7:19:04 AM New-HardDisk Invalid configuration for device '1'.
At line:1 char:1
+ New-HardDisk -vm $vm -DiskPath $disk0.Filename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-HardDisk], InvalidDeviceSpec
+ FullyQualifiedErrorId : Client20_VirtualDeviceServiceImpl_AttachHardDisk_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.NewHardDisk
Any comments and help are really appreciated! Not sure if I'm missing a parameter or if I need to add the existing vmdk to the vm in a different way. I'm using vcenter server 6 and VMware PowerCLI 6.5 Release 1 build 4624819
Thanks in advance!