Skip to content

PowerShell detection methods and deployment status

Featured Replies

Hello everyone!

I wrote a simple PowerShell script to uninstall two different versions of a program A, and two different versions of program B. It's a basic "kill related processes, and then run msiexec /x". It works great, and it's packed into an application in SCCM 2012.

That being said, my results in the deployment status are confusing. Here is my detection method script:

if (!(Test-Path "C:\Program Files (x86)\Microsoft Office\Live Meeting 8"))

{

     write-host "Installed"

}

else

{

}

This path is "true" on every machine with the installed software. However, I deployed this application to 75 machines, and about 17 came back as successful, while 58 came back as "Successful: Already Compliant".

The removal script DID run; the software is gone and some of the directories I cleaned up in the script are also gone.

I just don't understand why it's coming back as "already compliant" when it clearly wasn't, and the application appears to have deployed successfully.

 

 

I'm obviously quite knew to SCCM, so please let me know if I can provide more information, or if I'm making a stupid mistake.

Thank you guys!!

Rather go for the product code of the msi in the installer database. Gambling with folders is not very clean, because of pending renames.

$ErrorActionPreference = "Stop"
if(!(gwmi -Namespace root\cimv2\sms -Class sms_installedsoftware -Filter "softwarecode = '{A8C8C39C-3CAB-4FB9-8A20-E70DABE84C91}' or softwarecode = '{A8C8C39C-3CAB-4FB9-8A20-E70DABE84C92}'")){return $true}



 

What you really should do, is defining your script as uninstall command in the deployment type of your application, instead as install command. This way you can use the product codes of your msi files as detection method, without scripted detection.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.