5 Replies Latest reply on Jul 27, 2018 10:32 AM by carlos

    PowerCLI (vsphere) script as a scheduled task

    carlos Expert

      EPM 2017.3

      i need to restore a snapshot before sending an install task on some clients, the vms are running in vmware, I was able to complete an script using powershell (in conjunction with powercli) to restore the snapshot, the thing is that to run the script, the machine that runs it has to have certaing prerequisites installed, powercli and some variables.

      So as far as I can see it now (I don't really know) I need to:

      1. Run the script from a machine with this configuration (I would need to have a machine in stand by just to run the powershell/powercli commands)

      2. Run my normal Software distribution task after the restore is completed.

       

      Is there another way to do this?

      I found this: Creating and deleting snapshots the reference doc is for hyper-v for which Normal powershell would work (installed on the core) but no the additional powercli requirements.

      Can I install powerCLI in my core?

       

      Any reference is appreciated.

      Best.

        • 1. Re: PowerCLI (vsphere) script as a scheduled task
          phoffmann SupportEmployee

          You should be "fine" with installing PowerCLI on the Core.

           

          Why on earth VMWare can't / won't "just" do normal web-services is beyond me, but ah well. That's a VMWare decision (which I question) - but you're right ... if you want to talk to VMWare you need one of the VMWare interfacing tools installed (annoyingly).

           

          I *would* suggest you install PowerCLI on a test Core first (just to make sure that they don't blow up anything obvious), but I can't think of anything it should fool around with (since usually the "more sensitive" components tend to be either IIS-related and/or .NET related).

           

          I wouldn't expect any problems, but if you don't make sure, "something will go wrong" - because sod's law.

           

          Alternatively, install PowerCLI on a "dedicated box" (say - one of your VM-s) and store your script(s) there, and just schedule the scripts to be launched from that box. You can access data from the Core if you need with your account via a dynamic query (for example) in Getting Started with the MBSDK (Example Scripts Included) .

          • 2. Re: PowerCLI (vsphere) script as a scheduled task
            carlos Expert

            I have an old core, I'll try the PowerCLI there and see if it works...

            I'm a little hesitant on installing anything on the core so I may have to test this carefully before passing it to production.

            I didn't want to have to setup and maintain an extra "box" just for this, but may be safer.... thinking... thinking

            I'll have to get back to you on this.

            Thx!

            • 3. Re: PowerCLI (vsphere) script as a scheduled task
              phoffmann SupportEmployee

              That paranoia / reluctance  to install "stuff" on the Core is a healthy thing! Don't knock it.

               

              <It's why I suggested nabbing some alternate device, so as to avoid fooling around with the Core and potentially causing headaches. >

              • 4. Re: PowerCLI (vsphere) script as a scheduled task
                Tim_Morris Rookie

                How did the PowerCLI install go on the core?

                 

                I'm wanting to create a scheduled task that snapshots a VM before installing patches.

                 

                I was thinking installing PowerCLI on the core might be the way to do that.

                • 5. Re: PowerCLI (vsphere) script as a scheduled task
                  carlos Expert

                  PowerCLI worked in my test core, BUT I didn't have the courage to put it in my production core.

                  Proceed at your own risk.

                   

                  Best.