Skip to content

Commit 00854b9

Browse files
authored
Merge pull request #87274 from mgreenegit/patch-1
add examples to collect logs
2 parents 6bea82c + 9902d76 commit 00854b9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

articles/governance/policy/concepts/guest-configuration.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,37 @@ Linux: `/var/lib/waagent/Microsoft.GuestConfiguration.ConfigurationforLinux-<ver
192192

193193
Where `<version>` refers to the current version number.
194194

195+
### Collecting logs remotely
196+
197+
The first step in troubleshooting Guest Configuration configurations or modules should be to use the `Test-GuestConfigurationPackage` cmdlet following the steps in
198+
[Test a Guest Configuration package](../how-to/guest-configuration-create.md#test-a-guest-configuration-package). If that is not successful, collecting client logs can help diagnose issues.
199+
200+
#### Windows
201+
202+
If you would like to use the Azure VM Run Command capability to capture information from log files in Windows machines,
203+
the following example PowerShell script can be helpful. For details on running the script from the Azure Portal
204+
or using Azure PowerShell, see [Run PowerShell scripts in your Windows VM with Run Command](../../../virtual-machines/windows/run-command.md).
205+
206+
```powershell
207+
$linesToIncludeBeforeMatch = 0
208+
$linesToIncludeAfterMatch = 10
209+
$latestVersion = Get-ChildItem -Path 'C:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\' | ForEach-Object {$_.FullName} | Sort-Object -Descending | Select-Object -First 1
210+
Select-String -Path "$latestVersion\dsc\logs\dsc.log" -pattern 'DSCEngine','DSCManagedEngine' -CaseSensitive -Context $linesToIncludeBeforeMatch,$linesToIncludeAfterMatch | Select-Object -Last 10
211+
```
212+
213+
#### Linux
214+
215+
If you would like to use the Azure VM Run Command capability to capture information from log files in Linux machines,
216+
the following example Bash script can be helpful. For details on running the script from the Azure Portal
217+
or using Azure CLI, see [Run shell scripts in your Linux VM with Run Command](../../../virtual-machines/linux/run-command.md)
218+
219+
```Bash
220+
linesToIncludeBeforeMatch=0
221+
linesToIncludeAfterMatch=10
222+
latestVersion=$(find /var/lib/waagent/ -type d -name "Microsoft.GuestConfiguration.ConfigurationforLinux-*" -maxdepth 1 -print | sort -z | sed -n 1p)
223+
egrep -B $linesToIncludeBeforeMatch -A $linesToIncludeAfterMatch 'DSCEngine|DSCManagedEngine' "$latestVersion/GCAgent/logs/dsc.log" | tail
224+
```
225+
195226
## Guest Configuration samples
196227

197228
Samples for Policy Guest Configuration are available in the following locations:

0 commit comments

Comments
 (0)