Change values in Com object (PsVirtualBox)

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of Jeffery Hicks Jeffery Hicks 3 months, 4 weeks ago.

  • Author
    Posts
  • #49873
    Profile photo of guru
    guru
    Participant

    I know this a simple question, but I'm not able to solve this thing. In psVirtualBox module,you can create a Com object using

     $V = Get-VirtualBox 

    Or we can use $VBOX variable. Say you want to change the memory of virtual machine. You use

     $VBOX.Machines.Memory = 1500

    But it's giving a error saying that the name memory didn't exist or can't be changed. But there is a set property over there. I'm able to see the memory using

     $VBOX.Machines.Memory 

    Could any one help me with this.

  • #49924
    Profile photo of Dan Potter
    Dan Potter
    Participant

    do this. $VBOX.Machines |gm and send the instructions for the methods if there are any.

    Is Jeff Hicks lurking around here?

  • #49934
    Profile photo of Jeffery Hicks
    Jeffery Hicks
    Participant

    It's possible that is a read-only property so you can't simply assign a new value. There's probably some COM method for changing the memory. Or I vaguely recall using the command line utility which I probably wrapped in a PowerShell function. I am amazed people still find this module useful. Perhaps I shouldn't be so quick to let it go. 🙂

  • #49958
    Profile photo of guru
    guru
    Participant

    Thanks Jeff, that module is a life saver for me.

  • #49963
    Profile photo of guru
    guru
    Participant

    The output if I ran

     $Vbox.Machines | gm 

    is

    MemorySize          Property   uint MemorySize () {get} {set} 

    I clipped others. It has a set property, but if I'm using

    $Vbox.Machines.MemorySize[0] = 1000 

    The memory value is not changing. Can you help me?

  • #50023
    Profile photo of Jeffery Hicks
    Jeffery Hicks
    Participant

    The COM stuff doesn't always work as you expect. I'd have to dig back into the Virtual Box SDK. Or I'd suggest simply building a tool around the command line vboxmanage.exe command line tool which you should find in C:\Program Files\Oracle\VirtualBox. The utility has parameters for modifying a VM including memory. Someone needs to overhaul this module. It would even be a good candidate to take advantage of classes in v5

You must be logged in to reply to this topic.