vCenter

 View Only
  • 1.  Help with a vi toolkit script please ?!??

    Posted Jun 18, 2009 06:50 AM

    All

    I have recently started scripting using Powershell and as great a language it is I'm still at the 'very' early learning stages. All I would like to do is create a script that reads some hosts from a text file and then gets some info off all the VMs associated within that host. I know the get-vm command can do that for ALL the VMs within VC but when i run my script it seems to get the info for the entire VC and NOT on a per host basis. (We have many hosts within the estate and require the VM info off only a couple)

    Heres my script so far (very basic i know!)

    $hostlist = (get-vmhost -Name (get-content c:\hosts.txt) | select Name)

    #Get VMs for each host

    foreach ($esx in $hostlist) {

    $VMs = get-vm

    foreach ($vm in $VMs) {

    Write-host $vm.Name

    Write-host $vm.MemoryMB

    Write-host $vm.numcpu

    Write-host $vm.Guest

    }

    }

    I know its really basic so far but all i am trying to acheive is to simply get some info about some of the VMs and report it back to the console (I'm sure I can send out the info to a spreadsheet myself so now worries there)

    Many thanks for you help in advance



  • 2.  RE: Help with a vi toolkit script please ?!??

    Broadcom Employee
    Posted Jun 18, 2009 07:50 AM

    You may want to pose your question in the PowerCLI forums or do a search for snippets of code regarding your question:

    =========================================================================

    William Lam

    VMware vExpert 2009

    VMware ESX/ESXi scripts and resources at:

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    If you find this information useful, please award points for "correct" or "helpful".



  • 3.  RE: Help with a vi toolkit script please ?!??

    Posted Jun 18, 2009 09:06 AM

    Perfect!

    Was a bit unsure about posting it here so thanks for pointing me in the right direction !

    Will move it to the relevant group



  • 4.  RE: Help with a vi toolkit script please ?!??

    Posted Jun 18, 2009 12:50 PM

    Have moved thread to PowerCLI forum