Running Powerscript in the "enduser" environment

This topic contains 4 replies, has 3 voices, and was last updated by  Ramon Tan 3 weeks, 3 days ago.

  • Author
    Posts
  • #103153

    Ramon Tan
    Participant

    I have created a useful script (PS 5.1 ISE) that will save my "enduser" about 6 steps in the production environment.
    The steps are simple: export file from ACCESS to Excel (csv), convert, copy, merge and save final results to Excel .xlsx format.
    I developed and tested the script in the PS (5.1) ISE environment. I now wonder what it would be like to "set it up" for my target user environment in the "least involved" (or "user firnedly") manner.

    1 – Should I expect the user to run PS ISE Admin, open the PS1 file and then run it?
    2 – Or is there a "friendlier way" — which in my view would be to simply ask the user to double-click the PS1 file (I tried this and it fails, perhaps because the enduser's environment isn't "hosted properly" to run my script;
    3 – Or can I ask the user to Run As Administrator [cmd.exe] from Windows Start, get into the traditional DOS prompt and then invoke the PS1 file? (I haven't tried this for fear it might mess things up on the production PC).

    Would be grateful for any advice, tips or suggestions.

  • #103159

    Don Jones
    Keymaster

    Double clicking doesn't work by design; it's a security feature.

    If you use SAPIEN editors, I know they can package a script into an EXE. Easy double click. You can also apply alternate credentials. It's probably my preferred way to achieve what you're after.

    • #103195

      Ramon Tan
      Participant

      Many thanks Mr Jones, much appreciated.

  • #103192

    postanote
    Participant

    If you users are not admins on the box, then your first bullet is moot, which lends to DonJ's comment regarding alternate creds as well.

    .Ps1 files are only seen as text files on the system by default, for the reason DonJ points out. Sure, you could reassign all .ps1 extenuation to powershell.exe, but don't, it will become and issue for you long term from a risk management (security) perspective.

    You could send the script with a shortcut to the user, then double-clicking the shortcut, if properly configured (using the runas setup) would execute the script. Yet, again, if you are installing , stuff, that requires admin, and the user is not and admin, then you have an issue anyway.

    You could use GPO and make it a run once thing on logon.

    Yep, Sapien, PSS is a good tool, been using it for years now, but you can create PS .exe without it, especially if you are strapped for cash yourself, or your company is unwilling to pay the annual subscription for it.

    Use the MS powershellgallery.com tools or stuff on TechNet.

    PS2EXE-GUI: "Convert" PowerShell Scripts to EXE Files with GUI

    Overworking of the great script of Ingo Karstein with GUI support. The GUI output and input is activated with one switch, real windows executables are generated. With Powershell 5.x support.

    'gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5'

    Create-EXEFrom.ps1: Create EXE from PowerShell script (with supplementary files)

    Takes one PowerShell script and any number of supplementary files or even a directory and creates an exe using Windows's built in iexpress program. The exe will run on any machine with PowerShell 2.0+.

    'gallery.technet.microsoft.com/Create-EXEFromps1-Create-efc8436c'

    Wrap your PowerShell scripts as Executables

    In order to do this I am leveraging the awesome capabilities of PowerShell, allowing me to locate the compiler at runtime and compiling my wrapper code into an executable. So let's examine this step by step.

    PowerShell Executable Generator
    'github.com/nyanhp/exewrapper'

    'blogs.technet.microsoft.com/japete/2017/09/11/wrap-your-powershell-scripts-as-executables'

    See this discussion on the .exe thing as well. Just so you know.
    'powershell.org/forums/topic/compile-ps1-to-exe'

    • #103198

      Ramon Tan
      Participant

      Thank you very much, your inputs are very helpful.
      Much appreciated.

You must be logged in to reply to this topic.