0

My team builds an on-premise application that works on Windows, Mac and Linux.

The application contains a bin directory with the startup scripts for the application.

bin
  startup.sh (for linux/mac)
  startup.cmd (for windows)

My team finds maintaining the old-school CMD code tedious, for good reason. I'd like to move our team to powershell instead of cmd.

bin
  startup.sh
  startup.ps1

However, I'm hesitant to do this because I don't see many other software applications package their stuff like this.

Is it because of the ps1 security thing where you have to allow ps1 files to be executable or what not? Why isn't powershell used for this purpose more often?

  • When pointing to the "ps1 security thing", do you mean the "executionpolicy" wich is set to "Restricted" below server 2012, right? – Harry Oct 20 '18 at 20:35
  • yeah. @Harry that was my terrible way of explaining that! lol – Nicholas DiPiazza Oct 20 '18 at 20:36
  • 1
    The default executionpolicy is one thing that deters people from using PS but it is also the existing investment in skills in writing batch/CMD files can deter some from switching to PS - one of my colleagues is a master when it comes to writing CMDs yet doesn't want to learn PS. Some of our new intake have little familiarity with the command line, CMD files and don't code in PS either as a result. One option you could look at is code signing - dependent on execution policy settings (remotesigned) or google 15 ways to bypass the powershell execution policy might give you some ideas. – Enigman Oct 20 '18 at 20:49
1
Why isn't powershell used for this purpose more often?

In your case "that purpose" translates to the need of providing an installer for a "cross platform application", like a java, python etc... application.

The question cannot be answerred directly, but my best guess is that when a team builds "cross platform" solutions, the majority of team members are linux/unix guys that don't like microsoft and possibly even apple a lot.

The problem is that when it gets to large installations (enterprise) of clients, microsoft/windows is the only way to go because of the existence of "active directory".

My team finds maintaining the old-school CMD code tedious, for good reason. I'd like to move our team to powershell instead of cmd.

This "good reason" just means that not all of your team members are experts in "Windows batch language" - but with shell script they are O.K. - both languages are tedious to maintain. They could also complain about shell script and make you think about changing to python.

Powershell is a scripting language compareable to scala for java. Only admins with programming skills can use powershell but on the other hand, programmers with admin skills already use csharp. I believe that is the reason for the lack of use of powershell

The task of "installation" always requires very deep understanding of the OS. My recommendation for integrating well into windows is that you educate 2 team members to some microsoft courses: MCSE or MCSA.

Last but no least, from my personal experience the only problem changing from .bat to .ps1 is that you need to take care about the execution policy and signing. In large enterprises you need ask for the default permission policy in active directory to be changed which can take months. Batch always works.

[A very prominent related example is the "compass" application within the official "mongodb" installer. On OS <2012 (e.g. win7) it just hangs because of the default ps1 execution policy is "don't run anything"]

  • By the way, you would still need some batch to ensure that the needed version of powershell is available. From experience huge companies end up buying some installer like installshield. – Harry Nov 23 '18 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.