This is a short blog post about remotely capturing ConfigMgr client log files to a file share for troubleshooting purposes.
With the ever-increasing security, not all teams supporting endpoints necessarily have Admin access for troubleshooting. Part of which includes analyzing logs.
You may experience scenario where the device is not even on corporate network and you need to capture logs.
We can use the power of Run Scripts feature to capture logs remotely against a single machine or a collection of devices and dump it against a file share for analysis.
Reference: https://docs.microsoft.com/en-us/sccm/apps/deploy-use/create-deploy-scripts
Here’s the sample script I have use for this purpose:
# Specify destination share
$dest = "\\<server>\Share"
# Specify the ConfigMgr log file location
$source = "c:\windows\ccm\logs"
# Capturing Machine Name
$hostname = hostname
# Capturing current date and time
$date = get-date -Format MM-dd-yy-hh-mm
# Creating a folder in the destination share location to match the Computer name followed by Date and Time.
mkdir $dest\$hostname-$date
# Copying files to the destination
Copy-Item -Path $Source\* -Destination $dest\$hostname-$date -Recurse
The sample script provided here is not supported under any Microsoft standard support program or service. All scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Note: I have specified a local file share which means, only machines that can access this network share will be able to upload logs. You may create separate shares based on locations, alternatively you can also choose an Azure storage path for upload. Additionally, a network file share also requires firewall port exceptions.
If you are interested in uploading the logs to Azure, for devices outside corporate network managed via CMG.
First, we create an Azure File Share.
Using the same script reference for file share, we can add the Azure drive connection information.
# Paste the Azure File Share Drive Connection Info. Here
# End of Azure File Share Drive Connection Info.
# Specify destination share
$dest = "Z:\"
# Specify the ConfigMgr log file location
$source = "c:\windows\ccm\logs"
# Capturing Machine Name
$hostname = hostname
# Capturing current date and time
$date = get-date -Format MM-dd-yy-hh-mm
# Creating a folder in the destination share location to match the Computer name followed by Date and Time.
mkdir $dest\$hostname-$date
# Copying files to the destination
Copy-Item -Path $Source\* -Destination $dest\$hostname-$date -Recurse
# Remove mapped Z drive
Remove-PSDrive -Name Z -Force
The sample script provided here is not supported under any Microsoft standard support program or service. All scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
Now that our script is ready, we can execute this against a single device to validate. You may need to set the PowerShell execution Policy to Bypass if the scripts are not signed.
The captured log files should now be copied to the server share you specified in the script inside the folder matching the source computer name followed with date and time.
You can view the Azure logs directly from the portal or via Azure Storage Explorer
Refer the scripts.log on the client machine.
Thanks,
Arnab
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.