Automating with Jenkins and PowerShell on Windows (Web UI for PowerShell Scripts)

Discussion in 'Business & Enterprise Computing' started by Hodge, Mar 5, 2015.

  1. Hodge

    Hodge Member

    Joined:
    Feb 24, 2005
    Messages:
    48
    Location:
    Chatswood
  2. PabloEscobar

    PabloEscobar Member

    Joined:
    Jan 28, 2008
    Messages:
    12,698
    I read that when linked from Reddit, and thought it sounded good, we do something similar with Orchestrator, but writing/debugging orchestrator powershell sucks 80 kinds of balls (its 32 bit powershell 2.0 and if you want more, you have the shell to right powershell exe and then return your results back up the chain and publish back to the data bus)

    What user context do the scripts run in? do they run as the user logged into jenkins? or as the service account that jenkins is running as?

    How are results fed back to display to the user? Say I've got a script that displays all users in an OU, can I get Jenkins to display that back in a browser? or do I need to configure a share, and dump files out to it?

    My issue with most of these type of solutions (rundeck, jenkins, orchestrator etc) is their job based nature, I'd love a web service that could be used to trigger powershell, and return the console output to the browser (and/or prompt the user for more input if required)
     
  3. OP
    OP
    Hodge

    Hodge Member

    Joined:
    Feb 24, 2005
    Messages:
    48
    Location:
    Chatswood
    Orchestrator sounds awful!

    The accounts run as a local system I believe.

    It displays all console output back to the browser. So in your situation, targeting AD, I would setup a PS Remoting session, connect to your domain controller. query for the info and output it to the screen.

    Jenkins also will show what's happening live, as in your browser will show new info line by line as it happens.

    Here is one of my jobs which renames a PC, reboots, Joins domain, reboots, installs Chef client, and runs a Chef job:

    [​IMG]

    I am using things like:

    Code:
    $variable | Convertto-Json
    to show my variables in a json format, and also doing a fair bit of
    Code:
    Write-Output
    in there, but as you can see, its possible :)

    I will put more details about this in the next post.
     
  4. PabloEscobar

    PabloEscobar Member

    Joined:
    Jan 28, 2008
    Messages:
    12,698
    Cheers for the reply. I'd love to see how you set it up for remoting. I didn't think the Local System account had access to do anything over the network?

    What is the output of

    Code:
    Write-Output $env:USERNAME
    when launched via Jenkins? Perhaps its running as Network Service? either way, I'm excited to see how it interacts with remote computers :)

    Converting all my scripts to something that a button-monkey can click on a web page would go a long way towards getting more time allocated to writing more scripts.
     
  5. Great_Guru

    Great_Guru Member

    Joined:
    Sep 5, 2001
    Messages:
    1,225
    Location:
    Australia
    Subscribing. Thanks for the post and thanks in advance for future postings.

    Jenkins would have been handy in my previous work place buidling VM's on demand via web interface.

    Is it possible to implement workflow/approval systems into jobs? I tried searching the jenkins wiki but for some reason it's horrendously slow right now (maybe OCAU are jumping on the bandwagon :lol:)

    Department wants to build a dev VM, task waits on gatekeeper (manager approval). Would this be done by department manager logging into portal, click approve job, task happens.
     
  6. colmaz

    colmaz Member

    Joined:
    Jan 8, 2007
    Messages:
    410
    Location:
    Perth, WA
    Subscribing for interest. We have a custom made app (developed by one of our juniors) which is a web interface which runs PowerShell scripts, some on a schedule, some on a button click. If we could look at either integrating this, or replacing the custom app, that would be awesome.
     
  7. OP
    OP
    Hodge

    Hodge Member

    Joined:
    Feb 24, 2005
    Messages:
    48
    Location:
    Chatswood
  8. thetron

    thetron Member

    Joined:
    Dec 23, 2001
    Messages:
    8,167
    Location:
    Somewhere over the Rainbo
  9. Mystro1

    Mystro1 Member

    Joined:
    Jun 27, 2001
    Messages:
    689
    Location:
    Victoria Point, QLD
    This looks interesting, thanks for the post.
     

Share This Page