Diskpart Repartition - Shrink C: Partition & Create M: Partition
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is the latest version.

1Diskpart Repartition - Shrink C Drive & Add New Partition3/21/2018 1:48:04 PM
2Diskpart Repartition - Shrink C: Partition & Create M: Partition4/10/2018 9:44:03 AM

Description

Requests new partition size to be:

  1. Maximum: 49% of drive size if at least 59% of drive is free, leaving at least 10% free
  2. The greater of:
    1. Current free space of drive less 10% of total drive size
    2. 49% of free space of drive
    3. 20 GB minimum

Repartitioning will probably fail on dynamic and dynamic disks, but should work on both GPT and MBR.

If you change the drive name (line 22) or drive letter (line 23), please also update the relevance to match.


Property Details

ID25433
StatusProduction - Fully Tested and Ready for Production
TitleDiskpart Repartition - Shrink C: Partition & Create M: Partition
SourceInternal
Source Release Date3/2/2018 12:00:00 AM
Keywordsdiskpart disk repartition partition format partitions shrink extend drive
Is TaskTrue
Added by on 4/10/2018 9:44:03 AM
Last Modified by on 4/10/2018 9:46:42 AM
Counters 4340 Views / 8 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

isWindows (Relevance 1172)
Used in 1152 fixlets and 538 analyses   * Results in a true/false
Show indented relevance
windows of operating system
Used in 1 fixlet   * Results in a true/false
Show indented relevance
if (NOT (exists ((volumes of drives) whose (it = "MDT")) OR exists drive "M:")) then ((free space of drive of system folder / 1024 / 1024 / 1024 /*gigs*/) >= 20 /*gigs*/) else false

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
// continue if {(last 1 of (selects "Partitions from Win32_DiskDrive" of wmi as string)) as integer < 4}

// Preventative cleanup of unallocated space
delete mdtreclaim.txt

createfile until END
select volume c
extend noerr
exit
END

move __createfile mdtreclaim.txt
waithidden cmd.exe /c diskpart /s mdtreclaim.txt


// Main repartition operation
delete mdtdrive.txt

createfile until END
select volume c
extend noerr
shrink desired={if ((free space of drive of system folder / 1024 / 1024 ) - (total space of drive of system folder / 1024 / 1024 * 10/100)) > (total space of drive of system folder / 1024 / 1024 * 59/100 /* increased to 59% to account for leftover free space */) then (total space of drive of system folder / 1024 / 1024 * 49/100) else ((free space of drive of system folder / 1024 / 1024) - (total space of drive of system folder / 1024 / 1024 * 10/100))} minimum=20000
create partition primary
format quick fs=ntfs label="MDT" noerr
assign letter="M"
exit
END

move __createfile mdtdrive.txt
waithidden cmd.exe /c diskpart /s mdtdrive.txt

waithidden cmd.exe /c diskpart /s mdtreclaim.txt

delete mdtdrive.txt
delete mdtreclaim.txt
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!