Detection Method using PowerShell not working using True or False

Mike Jones 61 Reputation points
2021-03-29T17:30:13.34+00:00

Hi,

I am trying to deploy X64 Version of Teams and even though the below script for my detection method is outputting False it says the machine is already compliant in SCCM. This is a user based installation and I ran the script under the user context on the PC and the result was False but SCCM reports already compliant. Is there an issue when using a detection method like this that results in a true or false?

if (Test-Path $("${Env:LOCALAPPDATA}"+"\Microsoft\Teams\current\Teams.exe"))
   {
$teamsexecutable = get-item ("${Env:LOCALAPPDATA}"+"\Microsoft\Teams\current\Teams.exe")
if (!($teamsexecutable.length -eq 90941720)){
$teamscurrentversion = ([System.Diagnostics.FileVersionInfo]::GetVersionInfo($teamsexecutable)).ProductVersion 
[version]::Parse("$teamscurrentversion") -ge [version]::Parse("1.4.00.2879")
}
}
Microsoft Configuration Manager Application
Microsoft Configuration Manager Application
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Application: A computer program designed to carry out a specific task other than one relating to the operation of the computer itself, typically to be used by end users.
456 questions
Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. AlexZhu-MSFT 5,551 Reputation points Microsoft Vendor
    2021-03-30T01:51:44.527+00:00

    Hi,

    According to this article, if script is used, both STDOUT and STDERR should be empty when application is regarded as "not installed"

    https://learn.microsoft.com/en-us/previous-versions/system-center/system-center-2012-R2/gg682159(v=technet.10)#to-use-a-custom-script-to-determine-the-presence-of-a-deployment-type

    82596-sccm-detection-method.png

    I've changed the script slightly and you may have a try to see if it works.

     if (Test-Path $("${Env:LOCALAPPDATA}"+"\Microsoft\Teams\current\Teams.exe"))  
     {  
    	 $teamsexecutable = get-item ("${Env:LOCALAPPDATA}"+"\Microsoft\Teams\current\Teams.exe")  
    	 if (!($teamsexecutable.length -eq 90941720))  
    	 {  
    		 $teamscurrentversion = ([System.Diagnostics.FileVersionInfo]::GetVersionInfo($teamsexecutable)).ProductVersion   
    		 if ([version]::Parse($teamscurrentversion) -ge [version]::Parse("1.4.00.2879"))  
    		 {  
    			write-host "installed"  
    		 }  
    		 else  
    		 {  
    		 }  
    	 }  
     }  
      
    

    Regards,

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful