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.