ConfigMgr – PowerShell Script to collect remote log files

Looking at a client’s ConfigMgr Agent log files is inevitable when managing a Configuration Manager infrastructure. If you are working within a local area network only, then you will most likely just connect to the remote systems configuration manager log folder and drag and drop the appropriate log files into CMTrace.exe. But if your clients are distributed across a WAN network with slow network links opening the log file from a remote location is probably not the most efficient way for analyzing the log files content. And because troubleshooting typically requires looking at multiple log files you finally end up copying multiple log files or just the whole log folder to your client to open them locally.

I have therefore created the  below listed Get-RemoteCMLogs.ps1 PowerShell script that does the following:

  1. Connect to the remote client via PowerShell Remoting
  2. On the remote client start a process to create a ZIP file containing the ConfigMgr logs folder and windowsupdate.log
  3. From the remote client create a new remote connection back to the host that invoked the script
  4. Transfer the ZIP file through the PowerShell Remoting session and store it locally with the users Documents Folder

The script uses two additional functions written by others. The ZIP File functions was written by Ken Sweet and the Send-File function was written by Lee Holmes.

Note that the use of this script requires that Windows Remote Management (WinRM) is enabled within your environment.

After you have downloaded the script from here. Open a PowerShell command prompt and enter

Get-RemotCMLogs.ps1 -Computer <Computername>,<Computername>

Next you will be prompted to enter your credentials. Enter a username and password that has permissions on the remote and local client.


Once completed, you will have the log files stored in your Documents \ RemoteCMlogs folder.


Note that the script is written to work with Configuration Manager 2012 Clients. I am planning for an updated version that first checks the agent version and then detects the log folder location. If you want to use the script for ConfigMgr 2007 agents simply adjust the $CMLogFldr variable at the beginning of the script.

Any comments, inputs are welcome.

Happy log file collecting!

One Reply to “ConfigMgr – PowerShell Script to collect remote log files”

  1. This is to inform you that I had gone through your article it was very helpful for me as I was searching for a solution to open a remote SCCM2012 Client machine log file by CMtrace.exe which was spread across the globe through a WAN network. We are doing a Windows 7 Migration project from Windows XP Machines where if a task sequence fails, we need to troubleshoot it as soon as possible by checking the smsts.log file so my plan is not to copy the entire log file to My Document but I should be able to open the remote machine smsts.log file from my local machine through CMTrace.exe by the powershell script as soon as I enter the computer name into powershell I guess you are getting my point?

    Usually by typing the full UNC Path \\computername\c$\windows\ccm\logs\smsts.log I used to open the log file. for one machine it is ok but if it is several machine it is a time consuming job.

    So now I need a powershell script which should open the particular log file which is located in the remote machine as soon as I enter the computer name and it should open through the CMTrace tool from the local system itself from where I am working on….

Leave a Reply