Announcement

Collapse
No announcement yet.

Shutdown Vm guests

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shutdown Vm guests

    Hello to all,
    I want to shutdown multiple guest machies imported from a csv, but nothing it's working for me. I used this command:

    $vm = import-csv d:\machines.csv
    $vm | shutdown-vmguest

    Now I have this error
    Shutdown-VMGuest : The input object cannot be bound to any parameters for the c
    ommand either because the command does not take pipeline input or the input and
    its properties do not match any of the parameters that take pipeline input.
    At line:1 char:23
    + $vm | Shutdown-VMGuest <<<<
    + CategoryInfo : InvalidArgument: (@{Name=xp86-150}:PSObject) [Sh
    utdown-VMGuest], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.
    Cmdlets.Commands.ShutdownVmGuest

    If I manually insert a name in the variable it works
    $vm = get-vm xp86-081
    shutdown-vmguest -vm $vm


    Thanks

  • #2
    Re: Shutdown Vm guests

    You need to iterate through the $vm array using the foreach command

    http://www.computerperformance.co.uk...hell_loops.htm
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Shutdown Vm guests

      thanks that worked greate

      Comment


      • #4
        Re: Shutdown Vm guests

        Well done!
        Do you mind posting your final script? I was going to do one but other things intervened so only posted the link above
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment


        • #5
          Re: Shutdown Vm guests

          Here it is

          import-csv c:\vmware\removesnapshoot.csv | foreach{
          $SourceName = $_.SourceName
          $vm = Get-VM $SourceName
          $vm | shutdown-vmguest
          }

          Comment


          • #6
            Re: Shutdown Vm guests

            Many thanks!
            Rep++
            Tom Jones
            MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
            PhD, MSc, FIAP, MIITT
            IT Trainer / Consultant
            Ossian Ltd
            Scotland

            ** Remember to give credit where credit is due and leave reputation points where appropriate **

            Comment


            • #7
              Re: Shutdown Vm guests

              I appologize if I hijacking this thread.. but Im curious after reading this thread.
              why do we have to complicate ourselves by trying to use this script to shutdown the guess machine?
              Won't the shutdown command in command prompt do the same job?

              Thanks,
              HN

              Comment


              • #8
                Re: Shutdown Vm guests

                Yes, but if you have 15-20 guests on a single host, would you want to do a shutdown on each of them manually?

                "Least Administrative Effort"
                Tom Jones
                MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
                PhD, MSc, FIAP, MIITT
                IT Trainer / Consultant
                Ossian Ltd
                Scotland

                ** Remember to give credit where credit is due and leave reputation points where appropriate **

                Comment


                • #9
                  Re: Shutdown Vm guests

                  In my case I have ~600 vm's so without PowerCLI I'm a "dead man".

                  Comment


                  • #10
                    Re: Shutdown Vm guests

                    Now I see the logics .. I wasnt meant to be a smart *ss.. I was curious

                    HN

                    Originally posted by Ossian View Post
                    Yes, but if you have 15-20 guests on a single host, would you want to do a shutdown on each of them manually?

                    "Least Administrative Effort"
                    Originally posted by adispy View Post
                    In my case I have ~600 vm's so without PowerCLI I'm a "dead man".

                    Comment


                    • #11
                      Re: Shutdown Vm guests

                      no stress...

                      Comment

                      Working...
                      X