Announcement

Collapse
No announcement yet.

Command line shutdown and restart

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

  • Command line shutdown and restart

    I want to automate a scheduled shutdown so I can copy the vhd file, then restart and wondered if anyone has some ideas.

    I've found a VBScript but I'm interested to know if anyone has done it this way or has an alternative method, maybe Powershell?

    Thanks in advance

  • #2
    Re: Command line shutdown and restart

    is this any use ?
    http://www.infotechguyz.com/cmd/powe...eshutdown.html

    (source: google. first hit for "powershell shutdown script")

    It's probably not exactly what you need, but you could modify it.
    Please do show your appreciation to those who assist you by leaving Rep Point https://www.petri.com/forums/core/im.../icon_beer.gif

    Comment


    • #3
      Re: Command line shutdown and restart

      What virtual solution are you using? VirtualPC? VirtualServer?
      What OS is the host running?

      Sorin Solomon


      In order to succeed, your desire for success should be greater than your fear of failure.
      -

      Comment


      • #4
        Re: Command line shutdown and restart

        Virtual Server can be managed via WMI or COM interface.

        Create a list of guests to shut down. Send each guest OS shutdown call and wait for a while. Check that guests are shutted down, if not force power off -state. Back up stuff and start your machines.

        Here are some sample scripts.

        .vP

        Comment


        • #5
          Re: Command line shutdown and restart

          Cheers chaps, we're running a mixture of 2005 Virtual Servers (and Hyper-V)

          The aim is to try and run a schedule on the physical server to cleanly shutdown the VS's (2003 for starters).

          While shutdown, backup the vhd's

          I've found this for 2003 Server

          This shutdown

          On Error Resume Next

          Set objVS = CreateObject("VirtualServer.Application")
          Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

          Set objGuestOS = objVM.GuestOS
          objGuestOS.Shutdown()

          ..and this starts up

          On Error Resume Next

          Set objVS = CreateObject("VirtualServer.Application")
          Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

          objVM.Startup()

          Though I need to confirm what I need on the server to run the files

          Comment


          • #6
            Re: Command line shutdown and restart

            This might help for the HyperV ones:
            http://www.infotechguyz.com/server20...HyperVvms.html
            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: Command line shutdown and restart

              What do you mean by
              what I need on the server to run the files
              ?
              The script you posted is VB, you can run it whenever you feel like it.
              Anyway, I suppose you know this is a poor method to backup virtual machines ...

              Sorin Solomon


              In order to succeed, your desire for success should be greater than your fear of failure.
              -

              Comment


              • #8
                Re: Command line shutdown and restart

                Originally posted by sorinso View Post
                What do you mean by ?
                The script you posted is VB, you can run it whenever you feel like it.
                Anyway, I suppose you know this is a poor method to backup virtual machines ...
                Yes, I'm aware it is VB so I can use apps like Cscript to execute it but this is to shutdown the VS's only, not to back them up, I can use a copy command to do that.

                If you can suggest a suitable method to automate the shutdown of 2005 VS's, I'm all ears.

                Btw guys, thanks for the Hyper-V suggestions, of which I'll look at once I'm happy with 2005

                Comment


                • #9
                  Re: Command line shutdown and restart

                  I think he meant that taking a copy of the VHD files isn't the best way to backup a VM.
                  Gareth Howells

                  BSc (Hons), MBCS, MCP, MCDST, ICCE

                  Any advice is given in good faith and without warranty.

                  Please give reputation points if somebody has helped you.

                  "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

                  "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

                  Comment


                  • #10
                    Re: Command line shutdown and restart

                    Originally posted by gforceindustries View Post
                    I think he meant that taking a copy of the VHD files isn't the best way to backup a VM.
                    Ahh, right.

                    Comment


                    • #11
                      Re: Command line shutdown and restart

                      Originally posted by gforceindustries View Post
                      I think he meant that taking a copy of the VHD files isn't the best way to backup a VM.
                      Indeed.
                      Although the VHD file contains the VM's hard disk itself, it is not the only thing you need to be able to recover a lost VM. There is also the configuration file, the network file, and of course, snapshots, if you have any. Might be also saved-states files, undo disks and so on and so on. And the matters get worse if you are using differencing disks in your machines.
                      That's why I mentioned that copying the VHD file cannot be considered a reliable (acceptable?) backup solution.

                      Sorin Solomon


                      In order to succeed, your desire for success should be greater than your fear of failure.
                      -

                      Comment

                      Working...
                      X