Change values in Com object (PsVirtualBox)

Welcome Forums General PowerShell Q&A Change values in Com object (PsVirtualBox)

Viewing 5 reply threads
  • Author
    Posts
    • #49873
      Participant
      Topics: 4
      Replies: 6
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 18
      Replies: 573
      Points: 32
      Rank: Member

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

      Is Jeff Hicks lurking around here?

    • #49934
      Participant
      Topics: 1
      Replies: 10
      Points: 22
      Rank: Member

      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
      Participant
      Topics: 4
      Replies: 6
      Points: 0
      Rank: Member

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

    • #49963
      Participant
      Topics: 4
      Replies: 6
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 1
      Replies: 10
      Points: 22
      Rank: Member

      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

Viewing 5 reply threads
  • The topic ‘Change values in Com object (PsVirtualBox)’ is closed to new replies.