Need to extract SCCM client install return code from ccmsetup.log file

Welcome Forums General PowerShell Q&A Need to extract SCCM client install return code from ccmsetup.log file

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
3 years, 3 months ago.

  • Author
    Posts
  • #32856

    Participant
    Points: 12
    Rank: Member

    I have the following code, but I need to extract the "return code" string as well as whatever numerical value is there, for instance a "0", or a 1", etc.

    I have no idea how to do this.

    Here is what I have so far and it works great, but I just want to extract "return code 0", or "return code 1".


    $SCCMClntReturnCode = @(
    Get-Content -Path "C:\Windows\ccmsetup\Logs\ccmsetup.log" |
    Select-Object -Last 1
    )

    Here is the actual string that I would like to extract from:

    ![LOG[CcmSetup is exiting with return code 0]LOG]!>

    Thank you all for your help.

  • #32901

    Keymaster
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You probably want to use the -match operator, along with a capturing regular expression. Once run, the built-in $matches variable will contain the captured values. This isn't necessarily easy stuff, but broadly speaking...

    "return code (?\d)"

    "return code " precedes what you want to capture, and so the (?\d) part would capture a single digit in a named capture group, named "code."

    http://www.heikniemi.net/hardcoded/2010/02/powershell-basics-4-matching-and-capturing-with-regular-expressions/ might have some more useful detail. There are some great examples.

The topic ‘Need to extract SCCM client install return code from ccmsetup.log file’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort