SCCM agent installation

Question

Hi Anoop/Team,

Got 180 devices without SCCM agent, need to install them in bulk.

Can you help me with any script file for the same or any best practices?

 

 

 

solved 0
Lakshmi Narayanan 7 months 9 Answers 142 views Beginner 1

Answers ( 9 )

  1. Client push is the the easiest option in this case.

    If client push is not working on few machines you may need to check the access for client push account on those problematic machines as you mentioned machines are from different domain, this would be the first suspect.

    Additionally you may need to check the client push required firewall ports are opened also if you are having local firewall all the necessary inbound and outbound rules are taken care for WMI communication.

  2. If still you are interested in doing it with PS Script only then here you go. Anoop has asked why are you not using SCCM Client Push.

    =========================================================================================================================

    Do
    {
    $ListOrManual = Read-Host “Would you like to run the script using an input list or manual entry? (L)ist/(M)anual”

    if ($ListOrManual -eq ‘L’) #If user chooses to use an input list
    {
    $TestList = Test-Path .Machines.txt #Tests if the input list is present

    if ($TestList)
    {
    $Date = Get-Date -Format yyyy.MM.dd-HH.mm.ss #Formats the date at script runtime to rename and move pre-existing files in order to avoid deleting potentially needed lists from previous runs
    Rename-Item -Path .OutputSuccess.txt -NewName Success-$Date.txt -ErrorAction SilentlyContinue
    Rename-Item -Path .OutputFailure.txt -NewName Failure-$Date.txt -ErrorAction SilentlyContinue
    Move-Item .Output*.txt .OutputArchive

    $PSExec = “.ExecutionPSExec.exe”

    $ComputersList = Get-Content .Machines.txt #Parse the input list and populate it in ComputersList
    $ComputersCount = $ComputersList.Count

    Write-Host “You are attempting to install the CM 2012 client on ” -NoNewLine; Write-Host “$ComputersCount devices.” -ForegroundColor Yellow
    $Confirm = Read-Host “Are you sure you want to proceed? Y/N” #Confirmation required to proceed

    if ($Confirm -eq ‘Y’)
    {
    $FailureCount = 0
    $SuccessCount = 0

    foreach ($Computer in $ComputersList) #Loop for each item in the input list
    {
    Write-Host “Running CM installation on $Computer”
    Remove-Item “\$ComputerAdmin$System32TasksMicrosoftMicrosoftConfiguration ManagerConfiguration Manager Client Retry Task” -ErrorAction SilentlyContinue #Removes the CM 2012 Client Retry Task that may be present due to a bug in CM2012 R2 Pre-SP1
    &$PSExec -s \$Computer cmd /c \$ServerHostingClientFilesCMClient_InstallInst_CM.cmd 2>$Var | Out-Null #PSExec will target the current machine in the list and run the CM manual client install script in SYSTEM context, PSExec output redirected to lala land

    if ($LastExitCode -Eq 0)
    {
    $Computer | Out-File -Encoding ascii -Append .OutputSuccess.txt #PSExec succeeded in copying the files and launching setup on the target machine
    Write-Host “CM installation ” -NoNewLine; Write-Host “was successfully launched” -ForegroundColor Green -NoNewLine; Write-Host ” on $Computer”
    Write-Host “————————————————–”
    $SuccessCount++
    }
    else
    {
    $Computer | Out-File -Encoding ascii -Append .OutputFailure.txt #PSExec failed in copying the files and launching setup on the target machine
    Write-Host “CM installation ” -NoNewLine; Write-Host “could not be launched” -ForegroundColor Red -NoNewLine; Write-Host ” on $Computer”
    Write-Host “————————————————–”
    $FailureCount++
    }
    }
    Write-Host “Finished executing on ” -NoNewLine; Write-Host “$ComputersCount devices:” -ForegroundColor Yellow -NoNewLine; Write-Host ” $SuccessCount installation(s) succeeded, ” -ForegroundColor Green -NoNewLine; Write-Host “$FailureCount installation(s) failed.” -ForegroundColor Red
    Pause
    }
    else
    {
    Write-Host “CM2012 client installation aborted by user!”
    Pause
    }
    }
    else
    {
    Write-Host “The Machines.txt list is missing. Make sure the file exists and is populated.” #If Machines.txt list is missing, inform the user running the script accordingly
    Pause
    }
    }
    if ($ListOrManual -eq ‘M’) #If user chooses to use manual target entry
    {
    $Target = Read-Host “Please input target machine name” #Takes from the user the target device to deploy to

    $PSExec = “.ExecutionPSExec.exe”

    Remove-Item “\$TargetAdmin$System32TasksMicrosoftMicrosoftConfiguration ManagerConfiguration Manager Client Retry Task” -ErrorAction SilentlyContinue #Removes the CM 2012 Client Retry Task that may be present due to a bug in CM2012 R2 Pre-SP1
    &$PSExec -s \$Target cmd /c \$ServerHostingClientFilesCMClient_InstallInst_CM.cmd 2>$Var | Out-Null #PSExec will target the current machine in the list and run the CM manual client install script in SYSTEM context, PSExec output redirected to lala land

    if ($LastExitCode -Eq 0)
    {
    Write-Host “CM installation ” -NoNewLine; Write-Host “was successfully launched” -ForegroundColor Green -NoNewLine; Write-Host ” on $Target”
    Write-Host “————————————————–”
    }
    else
    {
    Write-Host “CM installation ” -NoNewLine; Write-Host “could not be launched” -ForegroundColor Red -NoNewLine; Write-Host ” on $Target”
    Write-Host “————————————————–”
    }
    Pause
    }
    if ($ListOrManual -ne “L” -and $ListOrManual -ne “M”) #If user made a wrong selection
    {
    Write-Host “Incorrect selection made. Please input either ‘L’ to use a list or ‘M’ for manual entry …”
    }
    $Retry = Read-Host “Would you like to run the script again? Y/N” #Rerun script if desired
    }
    While ($Retry -eq ‘Y’)

    Write-Host “Have a good day!”
    Pause

    ========================================================================================================================

    Best answer
  3. If the machines are added in SCCM database with the help of System Discovery, easiest method would be to use Client Push Install from SCCM console.

  4. All the systems are in an office network or in public network or office network VPN connected?

  5. Software Update is another method. This is what I use mainly in my org. The details are in the link Anoop shared earlier.

  6. Hello – The best and easy way to have a group policy setup for SCCM client installation if those machines are domain joined. Try this https://docs.microsoft.com/en-us/mem/configmgr/core/clients/deploy/deploy-clients-to-windows-computers#BKMK_ClientGP

    Another option is to use perform a client push – if you all those machines visible in the SCCM console?

Leave an answer

Sorry, you do not have a permission to answer to this question .