LevT
Platinum Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору в источнике исходник красивше и читабельней # Create the 200 GB VHDX file $VHDXFile = 'D:\Tmp\VM-Archive.vhdx' New-VHD -Path $VHDXFile -Dynamic -SizeBytes 200GB # Mount (attach) the VHDX file Mount-DiskImage -ImagePath $VHDXFile # Initialize the VHDX file $VHDXDisk = Get-DiskImage -ImagePath $VHDXFile | Get-Disk -Verbose $VHDXDiskNumber = [string]$VHDXDisk.Number Initialize-Disk -Number $VHDXDiskNumber –PartitionStyle MBR -Verbose # Format the VHDX file with NTFS, and assign a driveletter (without getting prompted, hence the use of Add-PartitionAccessPath) $VHDXDrive = New-Partition -DiskNumber $VHDXDiskNumber -UseMaximumSize -Verbose $VHDXDrive | Format-Volume -FileSystem NTFS -NewFileSystemLabel VM-Archive -Confirm:$false -Verbose Add-PartitionAccessPath -DiskNumber $VHDXDiskNumber -PartitionNumber $VHDXDrive.PartitionNumber -AssignDriveLetter # Get the drive letter $VHDXDrive = Get-Partition -DiskNumber $VHDXDiskNumber -PartitionNumber $VHDXDrive.PartitionNumber $VHDXVolume = [string]$VHDXDrive.DriveLetter+":" # Enable DeDuplication (assuming you added the role) Enable-DedupVolume -Volume $VHDXVolume Set-DeDupVolume -Volume $VHDXVolume -MinimumFileAgeDays 0 # Copy the VMs to the VHDX file Copy-Item E:\Exported $VHDXVolume -Recurse # DeDup the VHDX file Start-DedupJob -Type Optimization -Memory 75 -Priority High -Volume $VHDXVolume -Wait # Defrag the VHDX file defrag $VHDXVolume /U /V /X # Unmount (detach) the VHDX file Dismount-DiskImage -ImagePath $VHDXFile -Verbose # Optimize the VHDX Mount-DiskImage -ImagePath $VHDXFile -Access ReadOnly Optimize-VHD -Path $VHDXFile -Mode Full Dismount-DiskImage -ImagePath $VHDXFile -Verbose # Optional, archive using WinRAR 5 (command line version) & 'C:\Program Files\WinRAR\Rar.exe' a 'D:\tmp\VM-Archive.rar' $VHDXFile | Всего записей: 17168 | Зарегистр. 14-10-2001 | Отправлено: 01:06 05-12-2016 | Исправлено: LevT, 01:27 05-12-2016 |
|