اسکریپت Powershell برای فشرده‌سازی فایل‌های VHDX

اسکریپت powershell

599

اسکریپت powershell شامل یک تابع به نام Compact-VHDX است که می‌توان با استفاده از آن سایز دیسک‌های VHDX را که به صورت Dynamic تعریف شده‌اند و بیشتر از فضای واقعی درون آن‌ها را اشغال کرده‌اند را کاهش داد.

فایل VHDX باید حتما در ابتدا غیرفعال یا dismount شود تا اسکریپت powershell بتواند به آن دسترسی داشته باشد.

برای استفاده فایل زیر را از گالری Technet دریافت نمائید و مطابق راهنمای فراهم شده به شرح ذیل از آن استفاده نمائید.

https://gallery.technet.microsoft.com/scriptcenter/Powershell-Script-to-ae5c00ba/file/126931/1/Compact-VHDX.rar

دریافت راهنما:

Help Compact-VHDX -Full

مثال:

Compact-VHDX -VHDXPath D:\Dynamic1.vhdx -SDelete .\sdelete.exe

راهنما:

NAME
Compact-VHDX

SYNOPSIS
Function to remove unused space in Dynamic VHDX file

SYNTAX
Compact-VHDX [-VHDXPath] [-SDelete] [[-LogFile] ] [-WhatIf] [-Confirm] []

DESCRIPTION
Function is designed to work on Dynamic VHDX files – not Fixed.

To reduce size of Fixed VHDX file convert it to dynamic first then use this function.
For example:
Dismount-VHD -DiskNumber 13 -Confirm:$false
Convert-VHD -Path ‘d:\Fixed1.vhdx’ -DestinationPath ‘d:\Dynamic2.vhdx’ -VHDType Dynamic
Where ’13’ is the disk number as shown in Disk Management/Computer Management.

Before using this script, empty space on the VHDX disk first by deleting un-needed and
temporary files, and emptying the recycle bin

PARAMETERS
-VHDXPath
Path to VHDX file

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

-SDelete
Path to the SDelete.exe tool.
The tool is bundled with this script for ease of use. It can be downloaded from
http://technet.microsoft.com/en-us/sysinternals/bb897443.aspx

Required? true
Position? 2
Default value .\SDelete.exe
Accept pipeline input? false
Accept wildcard characters? false

-LogFile

Required? false
Position? 3
Default value “.\Compact-VHDX-$(Get-Date -format yyyyMMdd_hhmmsstt).txt”
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf []

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm []

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

NOTES
Function by Sam Boutros
v1.0 – 10/12/2014

————————– EXAMPLE 1 ————————–

C:\ZAGRIO.COM\PS>Compact-VHDX -VHDXPath D:\Dynamic1.vhdx -SDelete .\sdelete.exe

RELATED LINKS
https://superwidgets.wordpress.com/category/powershell/
https://www.zagrio.com/

بدون دیدگاه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *