I need a script to be able to copy one .vmdk file from one datastore to another. I'm wanting to copy a block aligned formatted hd from a datastore to a newly created vm but I'm not wanting to do this manually everytime I create a vm. Any suggestions?
You can use the Copy-DatastoreItem cmdlet for that.
Seems I forgot about the Copy-HardDisk cmdlet.
Makes it even easier
For example:
$newLocation = "[DS2] NewFolder" $vmName = "PC1" Get-VM $vmName | Get-HardDisk | %{ Copy-HardDisk -HardDisk $_ -DestinationPath $newLocation }
This will copy all hard disks on PC1 to the new datastore.
Note that you need to be connected to an ESX(i) server, not the vCenter.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the Copy-DatastoreItem cmdlet for that.
Seems I forgot about the Copy-HardDisk cmdlet.
Makes it even easier
For example:
$newLocation = "[DS2] NewFolder" $vmName = "PC1" Get-VM $vmName | Get-HardDisk | %{ Copy-HardDisk -HardDisk $_ -DestinationPath $newLocation }
This will copy all hard disks on PC1 to the new datastore.
Note that you need to be connected to an ESX(i) server, not the vCenter.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference