SCCM 2012 - Deploy Agent Offline

Topics: Archive - General
Jul 18, 2014 at 10:22 AM
Hi there,

i build a Script to deploy the SCCM 2012 Agent offline, it still run as repair script to but i have a problem.
My Final Dialog doesn´t show anything, the scripts end silent but the agent runs.

I don´t understand why the POST Section doesn´t run, anyone and Idee?
# Variables
$FileCCMSetup = "$env:Windir\CCMsetup\ccmsetup.exe"
$File = "$env:WINDIR\CCM\CCMEXEC.EXE"

#*===============================================
# Variables: Script - Do not modify this section

$deployAppScriptFriendlyName = "Deploy Application"
$deployAppScriptVersion = [version]"3.1.3"
$deployAppScriptDate = "05/22/2014"
$deployAppScriptParameters = $psBoundParameters

# Variables: Environment
$scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Dot source the App Deploy Toolkit Functions
."$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"

$timeout = new-timespan -Minutes 10
$sw = [diagnostics.stopwatch]::StartNew()
$svc = Get-Service ccmexec
$HWInventory = "{00000000-0000-0000-0000-000000000001}"
$SWInventory = "{00000000-0000-0000-0000-000000000002}"
$DiscoveryDataRecord = "{00000000-0000-0000-0000-000000000003}"
$MachinePolicyRetrievalEvaluation = "{00000000-0000-0000-0000-000000000021}"
$FileCollection = "{00000000-0000-0000-0000-000000000010}"
$SWMeteringUsageReport = "{00000000-0000-0000-0000-000000000022}"
$WindowsInstallerSourceList = "{00000000-0000-0000-0000-000000000032}"
$SoftwareUpdatesScan = "{00000000-0000-0000-0000-000000000113}"
$SoftwareUpdatesStore = "{00000000-0000-0000-0000-000000000114}"
$SoftwareUpdatesDeployment = "{00000000-0000-0000-0000-000000000108}"

#*===============================================
#* END VARIABLE DECLARATION
#*===============================================

#*===============================================
#* PRE-INSTALLATION
If ($deploymentType -ne "uninstall") { $installPhase = "Pre-Installation"
#*===============================================

    # Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install and persist the prompt
    Show-InstallationWelcome -CloseApps "scclient" -CheckDiskSpace -PersistPrompt

    # Show Progress Message (with the default message)
    Show-InstallationProgress "CM12 Agent would be completely deinstalled, if installed otherwise Agent would be new installed with R2 CU1 Fix!!!"
    
#   Execute-Process -FilePath "$env:Windir\CCMsetup\ccmsetup.exe" -Arguments "/uninstall" -IgnoreExitCode "3"
    
if([IO.File]::Exists($FileCCMSetup) -ne $false)
{
    Execute-Process -FilePath "$FileCCMSetup" -Arguments "/uninstall" -IgnoreExitCode "3"
}   
    $strFileName="$env:programdata\Microsoft\Crypto\RSA\MachineKeys\19c5cf*"
    if (test-path $strFileName) { 
        Remove-Item $strFileName -Force
    }

        start-sleep -seconds 5
    
#*===============================================
#* INSTALLATION 
$installPhase = "Installation"
#*===============================================

    # Perform installation tasks here
    Execute-Process -FilePath "$dirFiles\ccmsetup.exe" -Arguments "/source:$PSScriptRoot\Files SMSSITECODE=YOURS DNSSUFFIX=YOURS SMSMP=YOURS SMSCACHEFLAGS=PERCENTDISKSPACE SMSCACHESIZE=25"

    

#*===============================================
#* POST-INSTALLATION
$installPhase = "Post-Installation"
#*===============================================

    # Perform post-installation tasks here

    while ($sw.elapsed -lt $timeout){
    if (test-path $file){
        return
        }
    start-sleep -seconds 5
}
    Wait-Process -Name ccmsetup
    
    start-sleep -seconds 59

    $svc.WaitForStatus('Running')
    
    start-sleep -seconds 59
    
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($HWInventory)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($SWInventory)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($DiscoveryDataRecord)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($MachinePolicyRetrievalEvaluation)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($FileCollection)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($SWMeteringUsageReport)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($WindowsInstallerSourceList)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($SoftwareUpdatesScan)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($SoftwareUpdatesStore)
    start-sleep -seconds 5
    ([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($SoftwareUpdatesDeployment)

    start-sleep -seconds 59
    
    Set-RegistryKey -Key "HKLM:\SOFTWARE\XXX\Installed\$installName" -Name "Version" -Value $appVersion 
    Set-RegistryKey -Key "HKLM:\SOFTWARE\XXX\Installed\$installName" -Name "Install Date" -Value $currentDate 
    Set-RegistryKey -Key "HKLM:\SOFTWARE\XXX\Installed\$installName" -Name "Hotfix" -Value KB2938441
    
    # Display a message at the end of the install
    Show-InstallationPrompt -Message "The installation of $appVendor $appName $appVersion is ready." -ButtonRightText "Ok" -Icon Information -NoWait
Coordinator
Jul 20, 2014 at 10:24 PM
What are you using to run launch the script? Can you post log files?
Jul 24, 2014 at 10:18 AM
Hi,

it´s now running, i delete all from WHILE Statement and work now with INVOKE and this is cool.
Thanks.