none
SCCM detection method script RRS feed

  • Question

  • Hello, 

    I'm trying to replace a SCCM package that runs an executable on the clients to kick off a patch cycle and update a .csv file with an application (using a .bat), but I'm running into difficulty with the detection method.  I want to use the file method on the .csv file, but you need an absolute date, not a variable.  The modify date changes every time the .exe runs, so an absolute date would need to be updated every time the application is deployed which is few times a month.  

    Does anyone have an example of a script that would detect the modify date as something like %currentDate%?  My other thought is copying a dummy file with a exact modify date that I would know and use the file method off that file.

    For clarity sake, we use Altiris to patch Windows.  The .exe is C:\Program Files\Altiris\Altiris Agent\Agents\PatchMgmtAgent\AeXPatchUtil.exe, and the .csv is InstallLog.csv in the same directory.  

    Friday, July 12, 2019 8:28 PM

All replies

  • Hello, 


    For clarity sake, we use Altiris to patch Windows.  The .exe is C:\Program Files\Altiris\Altiris Agent\Agents\PatchMgmtAgent\AeXPatchUtil.exe, and the .csv is InstallLog.csv in the same directory.  

    Altiris to patch windows ? and again SCCM to kick the deployments ? why not to move everything to SCCM instead of managing both tools .

    you can use powershell script with get-date -f dd-MM-yyyy hhmmss to get the date of the script that runs and identify with detection logic.


    Eswar Koneti | Configmgr Blog: http://www.eskonr.com | Linkedin: eskonr | Twitter: @eskonr

    Sunday, July 14, 2019 2:18 AM
  • Not sure what this means. "I want to use the file method on the .csv file, but you need an absolute date, not a variable."

    Post what you already have.


    Richard Knight | Collection Refresh Manager | Automate detection rules for patch \ msp files | Twitter

    Sunday, July 14, 2019 11:00 AM
  • if((get-date).adddays(-7) -gt filedate){"Not Compliant"}

    That will cause the application to evaluate as false if the file date is older than 1 week old.  Obviously you would need to write the line to gather the filedate.

    Sunday, July 14, 2019 5:34 PM

  •  
    Try the following scripts.
     
    $path = "C:\Program Files\Altiris\Altiris Agent\Agents\PatchMgmtAgent\InstallLog.csv"
    If (Test-Path $path){
    $lastwritetime = (Get-Item $path).LastWriteTime
    If (((Get-Date) - $lastwritetime).Days -gt 7) { "installed"}}
     
    Change the file location and number "7" to match the actual situation.
     
    Hope my answer could help you and look forward to your feedback.
     
    Best Regards,
    Ray

    Please remembers to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.



    Monday, July 15, 2019 8:50 AM
  • Thanks Ray!  This looks promising, I'll give this a try and if successul mark it as the answer.  

    As to why we have two platforms for patching, we want to move to SCCM for all workstations, but we have a lot of digging out of legacy systems before we can get there.  Hopefully in due time. 

    Tuesday, July 16, 2019 7:47 PM
  • Why not just use a package in ConfigMgr? Applications are best used to install (exactly as their name implies) Applications. Most everything else is best left as a package.

    Jason | https://home.configmgrftw.com | @jasonsandys

    Wednesday, July 17, 2019 5:22 PM
    Moderator
  • That worked, but then it didn't.  As time goes on the deployment running, successful stats would fall off into error with 0x1(1) Incorrect Function.  I've found that's a local Windows error, not from the deployment or SCCM.  I'll try to run that error and see if I can address it on the clients.  

    FYI, I had to change the client setting for running powershell execution policy to Bypass to allow the script to be run. 

    Thursday, October 10, 2019 3:29 PM