SCCM Configuration Item

Hello

I would like to start off with a disclaimer that I am rather new to the powershell game. Most of my experience generally revolves around PS app deploy.

I recently was asked to start digging in to CI/CB within SCCM and my first task is to come up with a script for Symantec DLP.

I am using Get-Process to determine if a single process is running but I am having problems getting a false return if one of multiple processes are not running.

Ultimately I need determine which of 2 processes could not be running and then start that process.

 

Thank you in advance for any feedback

It’s critical that if you are new, that you first spend the time to ramp up to prevent a lot of unnecessary frustration and confusion you rare going to encounter.

Do a search on Microsoft Virtual Academy on PowerShell and Youtube for no cost video training.

Use all the free eBooks on this site, read the full help file on any cmdlet you are trying to use, practice with the examples, then read the helpfile again, then pick up a few good books, like, ‘PowerShell in a Month of Lunches’, by the creator of this site, Don Jones. There are lots of free PowerShell eBooks on Microsoft’s websites.

See also: The PowerShell Survival Guide

We love to help,. but as a rule, you have to, show what you have or you leave us to guessing.
If you are trying to get all processes of a specific app, you just ask for that using a partial name.

# Get all running processes for Symantec
Get-Process | 
Where-Object {$_.mainwindowhandle -ne 0} | 
Select-Object -Property Name, MainWindowTitle | 
Where-Object -Property MainWindowTitle -Like '*calc*'

# Results

Name                 MainWindowTitle
----                 ---------------
ApplicationFrameHost Calculator     
Calculator           Calculator 

Hey BStarbuck8307

On a really basic level you’d use something like the script below.

The elements of it are to have the full path of the processes to be checked stored in an array, obtain all running processes and store them in a separate variable, and then iterate through each of the processes to be checked to see if it features in the running processes. If it doesn’t then it performs the action required.

But if you’re starting of a process manually bear in mind that

a) The process will run in the user context of the account that the powershell process is running in
b) The process will exit on log off and because the process will be a child process of the powershell session, it will also quit upon the powershell session ending.

Generally speaking unless it’s a service (in which case you use the dedicated xxx-Service cmdlets for management) you’re not likely to want to spark of a process in a powershell session that you want to continue to run afterwards (if i understand right you are getting sccm to do the execution of your script?). Are you sure these processes aren’t started via a windows service? Can you give some more details?

[pre]
$tocheck = @(‘/Applications/WhatsApp.app/Contents/MacOS/WhatsApp’, ‘/bin/zsh’, ‘/System/Library/CoreServices/Spotlight.app/Contents/MacOS/Spotlight’, ‘/bin/imaginary’)
$process = Get-Process | Select-Object -ExpandProperty Path
$tocheck.ForEach(
{
$status = $psitem -notin $process
if ($status) {
do something
}
}
)
[/pre]