3 Replies Latest reply on Mar 1, 2018 7:28 AM by Denis65

    Environment Manager package save as with PowerShell

    Denis65 Rookie

      Good afternoon clever types :-)

       

      I am wanting to perform a 'save as' within Environment Manager to save a package with  a new name.

       

      This is easy enough in the console, load the package and go to File | Save As

       

      As I am trying to automate certain steps, I am trying to perform this using PowerShell by first using the BeginPackageVersionDownload followed by ContinuePackageVersionDownload with all the required parameters set.

       

      The package does indeed download into an array which I then try to upload using BeginPackageVersionUpload but what happens is that the download package version is removed from the Management Center

       

      Has anyone been successful with this procedure and if so, can you offer any pointers please

       

      Any help gratefully received.

       

      Thanks in advance,

       

      Denis

        • 1. Re: Environment Manager package save as with PowerShell
          mattw SupportEmployee

          Hi Denis,

           

          It sounds like the Management Server is just replacing the existing package with the new one.

           

          I've not used this API set in a while, however I think you may have to use 'CreatePackage' & 'CreatePackageVersion' and then pass it into the BeginPackageVersionUpload.  That way the Management Server will see it as a new package and not replace the old one.

           

          Regards,

           

          Matt

          1 of 1 people found this helpful
          • 2. Re: Environment Manager package save as with PowerShell
            Denis65 Rookie

            Hi Matt,

             

            Thanks for the fast response - as I am trying to add a new version of an existing package, I have been just trying CreatePackageVersion so will have a try with your suggestion.

             

            Again, thanks for the fast reply

             

            Regards,

             

            Denis

            • 3. Re: Environment Manager package save as with PowerShell
              Denis65 Rookie

              Hi all, time for an update.

               

               

              I've had a bit more time to look into this and have managed to successfully create a new version (the goal is to create a new version of an existing package from an existing package version) and this appears correctly in the management console with the expected version number etc

               

               

              The process I used is to download the existing package version with 3 steps, BeginPackageVersionDownload, ContinuePackageVersionDownload and then BeginPackageVersionDownloadCompleted.

               

               

              Next step is to lock the destination package with LockPackage, then I can create the new package version with CreatePackageVersion and it's many parameters, followed by CreatePackageVersionCompleted, CommitPackageVersionCompleted, UnlockPackageCompleted and finally, UnlockPackage

               

               

              After this is done, I then upload my downloaded data using BeginPackageVersionUpload and ContinuePackageVersionUpload and finish this off with FinalisePackageVersion and CommitPackageVersion

              As some of our packages are over 3mb which seems to be the upload size limit, some cleverness is required in PowerShell using [Math]::DivRem to split the data into chunks - our packages have complete history within going back to early 2013 which is why they are so big !

               

               

              This is all accomplished using [ManagementConsole.WebServices]::Packages and works brilliantly, HOWEVER :-), there is an issue with the newly imported package version in that when loaded, it shows the original source name (see screenshot) and this also stops changes being made

              Untitled.png

               

              Behaviour is as if I have renamed the policy and once i remove the lock, the name changes back again

               

               

              I have spent a few hours on this today and cannot get to the bottom of it - does anyone have any idea what could be going on ?

               

               

              Thanks for looking,

               

              Denis