question

MikeJones-8961 avatar image
0 Votes"
MikeJones-8961 asked AlexZhu-MSFT edited

Detection Method using PowerShell not working using True or False

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")
 }
 }
mem-cm-generalmem-cm-application
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AlexZhu-MSFT avatar image
1 Vote"
AlexZhu-MSFT answered AlexZhu-MSFT edited

Hi,

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

https://docs.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.




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.