Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9268419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:48:31+00:00 2026-06-18T14:48:31+00:00

I have the below code and currently checks computer for version info and service

  • 0

I have the below code and currently checks computer for version info and service status.

The problem I have is that servers have the located .exe in different places:

  1. C:\program files\snare\snarecore.exe
  2. C:\program files (x86)\snare\snarecore.exe
  3. D:\apps\snare\snarecore.exe

How do I get the script below to run the right version? I think I can use the path that the service is checking? I am doing this all remotly and have rights to the server and works fine – but I am having to possiblt make three (or more!) scripts just based on all three locations of where the executable is!

Also, for the ones that have a space in the name (../program file..) where do I put the quotes so that powershell can read the whole line and not error out due to the space in the name?

CODE:

clear
$ErrorActionPreference = "silentlycontinue"

$Logfile = "C:\temp\output_cdrive.log"

Function LogWrite
{
    param([string]$logstring)

    Add-Content $Logfile -Value $logstring
}

$computer = Get-Content -Path c:\temp\servers2.txt

foreach ($computer1 in $computer){

$Service = Get-WmiObject Win32_Service -Filter "Name = 'Snare'" -ComputerName $computer1

    if (test-connection $computer1 -quiet) 
    {
        $version = (Get-Command ""\\$computer1\c$\Program Files (x86)\Snare\SnareCore.exe"").FileVersionInfo.FileVersion

            if($Service.state -eq 'Running')
            {
                LogWrite "$computer1 STARTED $version"
            }
            else
            {
                LogWrite "$computer1 STOPPED $version"
            }
    }
    else 
    {
        LogWrite "$computer1 is down" -foregroundcolor RED
    }
}

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:48:33+00:00Added an answer on June 18, 2026 at 2:48 pm

    you can check the pathname property of you service to get the exe location :

    PS>(Get-WmiObject Win32_Service -Filter "name='spooler'").pathname
    C:\Windows\System32\spoolsv.exe
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have four change() events that fire exactly the same code (see below),
I currently have a problem. I have a code that looks like the one
Currently I have a borderContainer layout as shown below: My code for this layout
I have a python psp page code is shown below. Currently it only prints
I currently have the following code below and I want to update the specific
I have a controller that stores various info (Ie. FormID, QuestionAnswerList, etc). Currently I
I currently have a database that within a loop checks a table if a
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have below code: class Program { static void Main(string[] args) { Task[] tasks
I have below code in html. <li class=selected runat=server id=lihome><a href=/ISS/home.aspx title=Home><span>Home</span></a></li> Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.