I use an XML file to store configuration for creating virtual machines. My Powershell script creates the VM but I get this error where I'm trying to pass the MemoryStartup
value into the new-vm
function.
I tried to fix this by specifying [int64] before my variable but no luck. I can read the data from the XML file but it sees it as a string and the function requires it to be an int64.
In my xml file I put: 4096MB
In my powershell script:
new-vm -ComputerName $Using:Hostname -name $Using:VMName -MemoryStartupBytes [int64]$Using:MemoryStartup
Error:
Cannot bind parameter 'MemoryStartupBytes'. Cannot convert value "[int64]4096MB" to type "System.Int64". Error: "Input string was not in a correct format."
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.HyperV.PowerShell.Commands.NewVM