st.vincent_guitar
st.vincent_guitar

Reputation: 25

Need modify this powershell code to use get-process

printf("%d\n", 42); /*This powershell script needs to use the get-process in order to read a value from a Splunk log, and return a value of 0 if successful or 1 if not. I need to use get-process, echo back the return value, and exit gracefully. The need to use get-process is what I was told to do. I'm learning powershell, would anyone share this knowledge? Here is what I'm starting with... */

$servers = "splunk"  
     {  
        $status = (get-process -Name<String[running]> ).Status  
        if ($status -eq "Running") {  
            "running!"  
        } else {  
            "down"  
        } 

'

Upvotes: 0

Views: 65

Answers (1)

Jamie McNamara
Jamie McNamara

Reputation: 50

Not Tested.

$status = (Get-Process -Name ProcessName -ComputerName Server01) 
    if ($status -eq "") {  
        "down"  
    } else {  
        "Running"  
    } 

`

Upvotes: 1

Related Questions