Select Page

In this post, we will learn how to remotely set up the SCCM client using some PowerShell commands.

There are many ways to deploy the configuration manager client as shown by Microsoft and also there are many reasons for reinstalling the client. One of the main reasons I find it worthwhile to reinstall the client is when a machine has a problem installing updates or the machine has not been formatted for over a year. Also, I usually proceed to reinstall the client when I see several empty folders in the ccmcache folder after emptying the cache using the Configuration Manager in Control Panel.

So instead of disrupting the user’s work, we can perform the setup remotely. In this post, we will show how to uninstall and reinstall the client using some PowerShell commands. There are some times when remote PowerShell is not enabled in your environment, so you can make use of Sysinternals’ PSEXEC, but we will cover that in another post.

Reinstalling the client can also be handy for when you have no time to troubleshoot issues or when all the options to fix a client are exhausted. For some, the reinstallation of the SCCM client can be daunting, but it is actually a very easy process as we will see.

We will start with the uninstall steps as usually is the first process to troubleshoot clients.

Removing SCCM Client Using PowerShell

1. Open Windows PowerShell ISE using an account with administrative rights on the remote computer

2. Copy and paste the line below, replacing it with the name of the remote machine

$computername = "Machine name"

This will define the variable for the remote machine name.

3. Select the line and press F8 or click on the Run Selection button

4. Copy the client files from the SCCM server to the remote computer running the command line below

Copy-Item "\\SCCM Server\sms_Site Code\Client" -Destination "\\$computername\c$\Temp\CMClient" -Force -Recurse

Don’t forget to change the names highlighted below.

Run the command line and wait until the copy finishes.

You can check the files on the remote computer using the command below. Paste it in File Explorer.

\\SomeMachineName01\c$\Temp\CMClient\Client

5. Run the command to uninstall the client using the code below

Select all three lines and run.

Invoke-Command -ComputerName $computername -ScriptBlock {
& 'C:\Temp\CMClient\Client\CCMSetup.exe' /uninstall | Out-Null
}

6. Open the ccmsetup.log on the remote machine using the command below in File Explorer and wait until the installation finishes

\\machinename\c$\Windows\ccmsetup\Logs\ccmsetup.log

The removal is finished with the error code 0.

Installing SCCM Client Using PowerShell

1. Open Windows PowerShell ISE using an account with administrative rights on the remote computer

2. Copy and paste the line below replacing it with the name of the remote machine.

$computername = "Machine name"

This will define the variable for the remote machine name.

3. Select the line and press F8 or click on the Run Selection button

4. Copy the client files from the SCCM server to the remote computer running the command line below

Copy-Item "\\SCCM Server\sms_Site Code\Client" -Destination "\\$computername\c$\Temp\CMClient" -Force -Recurse

Don’t forget to change the names highlighted below.

Run the command line and wait until the copy finishes.

You can check the files on the remote computer using the command below. Paste it in File Explorer.

\\SomeMachineName01\c$\Temp\CMClient\Client

5. Run the command to install the client using the code below

Invoke-Command -ComputerName $computername -ScriptBlock {
& 'C:\Temp\CMClient\Client\CCMSetup.exe' SMSCACHEFLAGS=PERCENTFREEDISKSPACE SMSCACHESIZE=30 /mp:SCCMServerName SMSSITECODE=SiteCode FSP=SCCMServerName /AllowMetered /BITSPriority:HIGH /forceinstall | Out-Null
}

Update the code with the names of your SCCM server and site code.

Select all three lines and run.

6. Open the ccmsetup.log on the remote machine using the command below in File Explorer and wait until the installation finishes

\\machinename\c$\Windows\ccmsetup\Logs\ccmsetup.log

The installation is complete when error code 0 appears at the end.