Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

resize-partition PowerShell - using a variable for size

$
0
0

Hello.

I'm trying to user the PowerShell command resize-partition as part of a RunBook task so I need to be able to specify the size as a variable. The -size element requires that you also add on the size type (e.g. kb, mb, gb, tb etc.) but this makes the command fail as its then passed as a string and it looks like it wants to be a UInt64.

I have tried various different ways such as:

$size = 300 + "gb"
$size = "300" + "gb" etc.


The error I get is:

PS C:\Windows\system32> Resize-Partition -DriveLetter E -Size $Size
Resize-Partition : Cannot process argument transformation on parameter 'Size'. Cannot convert value "300GB" to
type "System.UInt64". Error: "Input string was not in a correct format."

The only way I can get it working is to hardcode it in: '-size (300gb)'

Would anyone have any idea how to get this working? It must be possible.

Thanks, Joe


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>