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 Security Intune Configuration Manager Application
Microsoft Security Intune Configuration Manager Other
0 comments No comments
{count} votes

Accepted answer
  1. AlexZhu-MSFT 6,591 Reputation points Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.