-1

I would like to know how i could create an array in Power shell V3 to generate a list of software on a local machine with the letter L for running services?

1
  • 1
    What have you tried? Have you made any attempt on your own, or are you asking for people here to write the whole thing for you? What is the source of this list - where is it stored, what counts as "installed", and what is the distinction between services and software?
    – alroc
    Commented Feb 11, 2014 at 15:05

1 Answer 1

0

I don't know what you call a list of software on a local machine, but the following code creates a list of all Windows services on a machine with a letter "L" for those that are currently running.

$services = @() # create an empty array
$services = Get-Service | ` # get a list of services
    foreach {
        # project each element in the list to a new object with two properties:
        @{
            IsRunning = (&{ # "L" if a service is active, i.e. in "Running" status
               if ($_.Status -eq "Running") { "L" } else { "" } # or "" otherwise
            })
            Name = $_.Name  # a name of a service
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.