• 20Apr

    Below I’ve built this custom script that will completely remove the SCCM Client and wait until all processes have stopped. Once it’s uninstalled it will also remove any residual files left from a previous install and then run a fresh install of the client. In order for this script to work you must place it in the same directory as the setup files for the SCCM client. Then open up a PowerShell prompt as an Administrator and type the following command:
    PowerShell.exe -ExecutionPolicy ByPass ".\Invoke-SCCM-Client-Install.ps1" -Wait

    The following values have to be amended to work in your environment:
    "ccmsetup.exe /forceinstall /mp:[SCCM SERVER NAME] INSTALL=ALL SMSPROVISIONINGMODE=1 SMSSITECODE=[SCCM SITE CODE] FSP=[Fallback Status Point Name -- Optional Switch] /NoCRLCheck"

    After the script runs you can keep track of the script process by opening another PowerShell window and typing the following command:
    Get-Content $env:SystemRoot\System32\LogFiles\OSD\SCCM-Client\[Press "Tab" Key for LogFile Name] -Wait


    # Script: Invoke-SCCM-Client-Install.ps1
    # Description: Uninstalls current SCCM Client and Installs new Client.
    # Execution: PS> PowerShell.exe -ExecutionPolicy ByPass ".\Invoke-SCCM-Client-Install.ps1" -WindowStyle Hidden -Wait
    # Author: Harry Caskey // harrycaskey@gmail.com // www.harrycaskey.com
    # Last Modified: 2017-04-20
    #
    $logPath = "$env:SystemRoot\System32\LogFiles\OSD\SCCM-Client"
    New-Item -Path $logPath -Type Directory -Force | Out-Null
    $timeDate = Get-Date -Format "yyyyMMdd-HHmmss"
    $logFileName = $env:COMPUTERNAME + "_" + $timeDate
    #
    New-Item -Path $logPath -Type Directory -Force | Out-Null
    #
    #
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    #
    #
    if ($procMsiExec -or $procCCMExec -or $procCCMSetup) {
    Stop-Service -Name CcmExec -Force | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    "Processess have been stopped. Executing ccmsetup.exe /uninstall command..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "/uninstall" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 15
    do {
    Start-Sleep 10
    "Uninstall is running..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMExec -eq $null) -and ($procCCMSetup -eq $null))
    "Uninstaller has completed..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    }
    else {
    "No processess are currently started. Executing the uninstaller now..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "/uninstall" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 15
    do {
    Start-Sleep 10
    "Uninstall is running..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMExec -eq $null) -and ($procCCMSetup -eq $null))
    Remove-Item $env:SystemRoot\CCM, $env:SystemRoot\ccmsetup, "$env:SystemDrive\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft System Center" -Recurse -Force -ErrorAction Ignore
    Remove-Item HKLM:\SOFTWARE\Microsoft\CCMSetup -Force -ErrorAction Ignore
    "SCCM Client removed..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    }
    #
    #
    Start-Sleep -Seconds 15
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    #
    #
    "Starting SCCM Client install..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "ccmsetup.exe /forceinstall /mp:[SCCM SERVER NAME] INSTALL=ALL SMSPROVISIONINGMODE=1 SMSSITECODE=[SCCM SITE CODE] FSP=[Fallback Status Point Name -- Optional Switch] /NoCRLCheck" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    do {
    Start-Sleep 10
    "Installing SCCM Client..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMSetup -eq $null))
    Start-Sleep 120
    #
    Restart-Service -Name CcmExec
    Start-Sleep 120
    #
    # Machine Policy Retrieval Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Machine Policy Evaluation Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Application Deployment Evaluation Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # State Message Refresh
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Hardware Inventory Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    #
    #
    "Finished installing SCCM Client..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procCCMExec = Get-Process -Name ccmexec
    $procCCMExecStatus = $procCCMExec.ProcessName
    if ($procCCMExecStatus) {"CCMExec: Enabled" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force}
    else {"CCMExec: Disabled" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force}
    # Clean Up Process
    Remove-Variable procMsiExec, procCCMExec, procCCMSetup, logPath, logFileName -Force

  • 20Jun

    I ran into an issue where after deploying an image with SCCM 2012 R2 the client would not pickup the PKI certificate.  If you are not receiving packages from your server this could be why.  To resolve this you have to modify the “ProvisioningMode” registry key and clear the value in “SystemTaskExcludes” registry key.  To simply this and make sure this is working on all clients I would recommend pushing this registry setting out through group policy.

     

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CCM\CcmExec

    ProvisioningMode = True

    SystemTaskExcludes = [null]

     

     

  • 18Jun

    1) Download the Microsoft .NET Framework 4 (Standalone Installer) http://www.microsoft.com/en-us/download/details.aspx?id=17718

    – Copy this file to your SCCM server repository location.  Ex: \\SCCM\Source\dotNet4

    2) In the SCCM 2012 Console under Software Library > Application Management > Packages

    – Right Click Packages and “Create Package” > Name your package and point it to your repository \\SCCM\Source\dotNet4

    3) Select “Standard Program” > Give the program a name “Install” > Browse and select the “dotNetFx40_Full_x86_x64.exe”

    – Under Command Line type: “dotNetFx40_Full_x86_x64.exe /q /norestart /ChainingPackage ADMINDEPLOYMENT”

    Set the program to run “Whether or not a user is logged on”

    4) Hit okay and add this package to your Task Sequence.

    Tags: , , , ,

  • 03Aug

    I’ve run into issues where an SCCM client will get repaired and the cache size automatically goes back to 5120MB.  This causes a problem if you have applications that you are advertising that are bigger than 5GB.

    So my solution was to created a PowerShell script that first checks to see what the current cache size is and if it is not what I specified change it and restart the SCCM Client on the host.  If the client is set to the cache size I have specified then simply exit.  I have also set this PS Script to be a scheduled task so it frequently runs the check.  You can do this very easily through Group Policy (if desired).

    If you have any questions about this script, please feel free to contact me.


    # Script developed by Harry Caskey
    # harrycaskey@gmail.com
    # http://www.harrycaskey.com/
    # Please give me feedback on this script if it works for you!
    #

    # First thing is specify the WMI object you want to query.
    $CacheSize = 51200
    $Cache = Get-WmiObject -namespace root\ccm\SoftMgmtAgent -class CacheConfig
    # Then run this IF statement to check to see if the Cache Size does not equal (-ne) to the $CacheSize variable .
    If ($Cache.size -ne $CacheSize) {
    $Cache.size = $CacheSize
    $Cache.InUse = "True"
    # If the cache size does not equal to the $CacheSize variable then apply.
    $Cache.Put()
    # Restarts the service after the Put() command. This is optional, not required and not recommended if you are deploying this script with SCCM.
    #Restart-Service ccmexec
    Exit
    }
    Else {
    Exit
    }

    Here goes the script if you would like to download it: Set-SCCMCacheSize.zip

     

    – Harry Caskey

    Tags: , , ,

  • 25Jun

     

    By default Windows only allows you to run sysprep on an image 3 times.  Then Microsoft’s solution is to re-install and start a new image.  Well what happens if you need to update your image or make a change without having to go through the hassle of making your image exactly what you want?  Follow these steps:

    1. Start > Run > regedit
    2. HKEY_LOCAL_MACHINE\SYSTEM\Setup\Status\SysprepStatus
      • Set the following DWORD values:
        • CleanupState: 0x00000002 (2)
        • GeneralizationState: 0x00000007 (7)
    3. Start > Run > msdtc -uninstall
    4. Start > Run > msdtc -install
    5. Restart your machine.

    You should now be able to run sysprep! W00t!

    – Harry Caskey

    Tags: ,

« Previous Entries   

-->