I am working on a powershell script that looks for a defined process in order to stop it (and restart it, if it was running before) in order to perform an update of that software.
We use the Microsoft System Center Configuration Manager to perform that task.
Running the Powershell directly with user rights with the user accounts, finds the process. Running the Powershell directly script with admin rights with the user account finds the porcess. Running the Powershell via SCCM with user rights with the user accounts, does NOT find the process.
Here is a snippet that we use for debugging:
$fileName = "MyFile.exe"
$processes = Get-Process
foreach ($process in $processes) {
# Process found?
if ($process.MainModule.FileName -like "*\$fileName") {
Write-Host "Process found" -ForegroundColor Green
}
else{
Write-Host "Not the right process" $process.MainModule.FileName -ForegroundColor Red
}
}
Any ideas?
Based on @mklement0 I created a workaround:
The actual reason why the process can not be found in powershell by SCCM remains a mystery.