0

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?

John Fox
  • 310
  • 4
  • 15

1 Answers1

0

You can add the following parameter to Resize-Partition:

-ErrorAction Continue

it's a common parameter and allows you to choose how Powershell responds to errors with the cmdlet

Swisstone
  • 6,725
  • 7
  • 22
  • 32