Hi,
I am trying to shrink the windows drives and I have issues with variable
If I use the below command, it works
Resize-Partition -DriveLetter E -Size ((Get-Partition -DriveLetter E).Size - 10GB)
But I want to use a variable in defining the size using variable, how can I do it ?
Please help
You can do like this
$shrinkSizeGB = Read-Host "Enter Disk Size To Be Reduced In GB"
$shrinkSize = $shrinkSizeGB * 1GB
$newSize = (Get-Partition -DriveLetter E).Size - $shrinkSize
Resize-Partition -DriveLetter E -Size $newSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You mean like this?
$shrinkSize = 10GB
$newSize = (Get-Partition -DriveLetter E).Size - $shrinkSize
Resize-Partition -DriveLetter E -Size $newSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your reply.
For $shrinkSize = 10GB
How can I enter only number, I am GB to populated automatically from the input
$shrinkSize = Read-Host "Enter Disk Size To Be Reduced In GB"
Please help!!!
You can do like this
$shrinkSizeGB = Read-Host "Enter Disk Size To Be Reduced In GB"
$shrinkSize = $shrinkSizeGB * 1GB
$newSize = (Get-Partition -DriveLetter E).Size - $shrinkSize
Resize-Partition -DriveLetter E -Size $newSize
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That Worked.....Thank you very much