2016-10-05 11:48:48 +00:00
|
|
|
Param(
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]$VmId,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
|
|
[string]$Path
|
|
|
|
)
|
|
|
|
|
2017-08-08 17:00:29 +00:00
|
|
|
$vm = Hyper-V\Get-VM -Id $VmId -ErrorAction "Stop"
|
|
|
|
$vm | Hyper-V\Export-VM -Path $Path
|
2016-10-05 11:48:48 +00:00
|
|
|
|
|
|
|
# Prepare directory structure for box import
|
|
|
|
$name = $vm.Name
|
|
|
|
Move-Item $Path/$name/* $Path
|
|
|
|
Remove-Item -Path $Path/Snapshots -Force -Recurse
|
|
|
|
Remove-Item -Path $Path/$name -Force
|