I'm trying to use the following piece of code in a powershell DSC script. It runs fine on first execution but on following executions it throws an error as it's already expanded.
Here's the command:
$MaxSize = (Get-PartitionSupportedSize -DriveLetter c).sizeMax
Resize-Partition -DriveLetter c -Size $MaxSize
What's the best way to get my script running with no error on subsequent runs?
You can add the following parameter to Resize-Partition:
it's a common parameter and allows you to choose how Powershell responds to errors with the cmdlet