Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Getting windows service status into variable

    Scheduled Pinned Locked Moved Support
    4 Posts 2 Posters 11 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      rwilson_1847
      last edited by

      I am working on using BuildMaster to handle automated deployments for some of our windows services. Everything seems fine except for one thing. For some services, we will have it deployed on multiple servers, but only have it running on certain ones. This is due to a mixture of redundency, server usage, etc. I can't seem to determine a manner in which I can get service startup type and/or current running status into a variable and act on it conditionally.

      I can see a manner in which I could use PSEval to pull this off, but wanted to make sure I wasn't missing a simpler solution.

      1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer
        last edited by

        Great to hear!

        Well, of course, you could store the information about which services are active in BuildMaster. I would imagine it's not something that changes very often, so perhaps this is OK?

        One approach might be to make a server role called hdars-service and then add a variable to that role called $ActiveServer with the server name. You would set a pipeline target to run deploy-hdars to hdards-service role, and in that plan, just do a if $ServerName == $ActiveServer to decide whether to start/stop service, or whatever.

        Otherwise, I think using powershell of some sort, whether $PSEval or a making an OtterSCript module with an output variable.

        1 Reply Last reply Reply Quote 0
        • R Offline
          rwilson_1847
          last edited by

          Sorry about the long delay in response.

          Your answer was helpful as I had not realized that roles could contain variables in that way. It will help with some other stuff I was thinking about doing.

          I did end up going with the powershell route as the some of our services do shuffle a bit. I think I have the script set up correctly, but when I execute the build step I get the following error:

          Unhandled exception: System.Management.Automation.Runspaces.PSSnapInException: An error occurred while attempting to load the system Windows PowerShell snap-ins. Please contact Microsoft Customer Support Services. ---> System.Management.Automation.PSArgumentException: Unable to access Windows PowerShell PowerShellEngine registry information.

          The agent is installed with the recommended user account. It's a Microsoft Server 2008 R2 server with service pack 1 and powershell 2. I couldn't find any information elsewhere on the site about how to resolve this. Help appreciated.

          1 Reply Last reply Reply Quote 0
          • R Offline
            rwilson_1847
            last edited by

            Error was related to how we had base install Windows Management Framework/Powershell installed. Updating to WMF/Powershell 4 resolved this error. Working through some mistakes in the scripting, but if I can get through it all without any more questions, I'll mark this post as answered.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation