Deploying Powershell Script using SCCM does not work for X64

Mike Jones 61 Reputation points
2020-10-12T19:17:04.563+00:00

Hi,

I have a script that repairs an application which has a x86 and x64 bit version of it installed. The script checks the folder size as follows:

$FolderX86Size = ((Get-ChildItem "C:\Program Files (x86)\TestApp" -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB)
if($FolderX86Size -lt 20 do repair....

$FolderX64Size = ((Get-ChildItem "C:\Program Files\TestApp" -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB)
if($FolderX64Size -lt 25 do repair....

When I run this script outside of Software Center it is working perfectly. When I run this script deployed as a "package" in SCCM it never tries to repair X64 but works for X86.

Is there something special required to get a script to work or be able to check correctly X64 folders within SCCM? TIA

Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. Jason Sandys 31,186 Reputation points Microsoft Employee
    2020-10-13T01:26:34.207+00:00

    There's no reason the above shouldn't work to my knowledge as both folders just be accessible from the 32-bit context of packages on 64-bit OSes. You should add logging to your script (perhaps using start-transcript) to capture detailed information and help troubleshoot.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Mike Jones 61 Reputation points
    2020-10-13T18:05:09.9+00:00

    Thank you, I got it working as it was because I didnt specify the sysnative powershell in my command in SCCM.

    0 comments No comments