Hi Guys
Im currently deploying an application via SCCM, and im using show-installationwelcome -close apps.
What im getting though is closure of all the apps on the VM for every user, not the current user.
The deploymenttype in SCCM is using ‘Install for system’ as there are also other parts I install for the system context, but i noticed that the AppDeployToolkitMain.ps1 using a standard get-process, which i think will get process names and id’s for all users no matter what, and compares against the $processNames object indiscrimintately.
Sorry for my complete ignorance, but is there a suggested way of just closing apps for the current user?
Cheers
Ian
I wrote code for killing explorer.exe under current user. Just change explorer.exe to name of another exe you want to kill.
Get-CimInstance win32_process -Filter "Name='explorer.exe'" | ForEach-Object {
$info = Invoke-CimMethod -MethodName "GetOwner" -InputObject $_ | Where-Object {$_.User -eq $RunAsActiveUser.UserName}
if ($info) {
Write-Log "Terminating process [$($_.Name) $($_.ProcessId)] running under [$($info.User)]" -Source "Terminate Process"
$null = Invoke-CimMethod -MethodName "Terminate" -InputObject $_
}
}
If you need to kill multiple, change the filter to
"Name='process.exe' OR Name='process2.exe'"
where you can keep adding new names separated with OR
Hi
Thanks that’s does the job
Ive added this to my deploy-application.ps1 and going to test on WVD – next step is to validate behaviour when a deployment type is set to System vs User.