Diskpart Repartition - Shrink C: Partition & Create M: Partition
0 Votes |
Versioning - This is the latest version.
1 | Diskpart Repartition - Shrink C Drive & Add New Partition | 3/21/2018 1:48:04 PM |
2 | Diskpart Repartition - Shrink C: Partition & Create M: Partition | 4/10/2018 9:44:03 AM |
Description
Requests new partition size to be:
- Maximum: 49% of drive size if at least 59% of drive is free, leaving at least 10% free
- The greater of:
- Current free space of drive less 10% of total drive size
- 49% of free space of drive
- 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
25433 | |
Production - Fully Tested and Ready for Production | |
Diskpart Repartition - Shrink C: Partition & Create M: Partition | |
Internal | |
3/2/2018 12:00:00 AM | |
diskpart disk repartition partition format partitions shrink extend drive | |
True | |
rdshift on 4/10/2018 9:44:03 AM | |
rdshift on 4/10/2018 9:46:42 AM | |
4340 Views / 8 Downloads | |
* Average over 0 ratings. ** Log In or Register to add your rating. |
Relevance
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}Success Criteria
// 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
This action will be considered successful when the applicability relevance evaluates to false.
Sharing
Social Media: |