Skip to main content

 

PowerShell DSC log amount issue on operating system drive

Overview

When using PowerShell DSC on a configured system in some (seldom) cases it can lead to log amount issues in a specific folder. The following folder grows (over time) so several GB size holding hundreds and thousands of JSON log files as visible in the following screenshot:


Also sometimes it looks like this:



Problem

The problem is (but must not be) related to DSC configuration issues as far as it could be analyzed. The log folder ā€žConfiguration Statusā€œ is filled with sometimes up to 7 Megabyte sized JSON files. This log folder (based on our analysis) is used for sending reports to report server but is not cleaned up automatically.

Impact

Some PowerShell DSC managed systems need extensive disk space due to log directory grown to 40 Gigabyte plus. This causes an alert in disk space / availability monitoring and could in some cases lead to non working windows operating systems.

Microsoft Ticket

For solving this a Microsoft ticket was openend ā€“ Ticket ID 2110180010001282. The result was the same as mentioned above. The behavior is ā€žby designā€œ. The PowerShell DSC parameter (in concrete LCM configuration parameter) ā€žStatusRetentionTimeInDaysā€œ is NOT the parameter for cleaning up this folder.

(Workaround) solution

The solution is more or less simple and also confirmed in a Microsoft case.

Just clean up this folder and delete the content which is not needed for DSC to work properly. Start an administrative PowerShell Session and use for example the following PowerShell commandlet:

Remove-Item -Path "C:\Windows\System32\Configuration\ConfigurationStatus\*.*" -Force

More enhanced solutions can check this folder regularly and delete in case some thresholds are hit.

The following script can be used, necessary authorizations provided, to check the folder size remotely:

# Get-DSCConfigurationFolderSizeT0.ps1

<#
.SYNOPSIS
Gets the folder size of the folder C:\Windows\System32\Configuration\ConfigurationStatus for all computers in the specified OU
.DESCRIPTION
Gets the folder size of the folder C:\Windows\System32\Configuration\ConfigurationStatus for all computers in the specified OU
#>

#Requires -Version 3.0

[CmdletBinding()]
Param
( 
)

#$computers = Get-ADComputer -SearchBase "OU=T0 Servers,OU=T0 Devices,OU=Tier 0,OU=Administration,DC=contoso,DC=com" -Filter {name -like "wsus01"}
$computers = Get-ADComputer -SearchBase "OU=T0 Servers,OU=T0 Devices,OU=Tier 0,OU=Administration,DC=contoso,DC=com" -Filter *

foreach ($computer in $Computers.name) {
try {
$MySession = New-PSSession -ComputerName $computer -ErrorAction Stop
Write-Host "$($computer)"
Invoke-Command -ScriptBlock {(gci C:\Windows\System32\Configuration\ConfigurationStatus | measure Length -s).sum / 1Gb} -Session $MySession -ErrorAction Stop
}
catch {
Write-Host $_
Remove-PSSession -Session $MySession
}

Write-Host "Closing Session"
Remove-PSSession -Session $MySession
Get-PSSession
}

References


Comments

Popular posts from this blog

ESM Log size is full - How to clear

                                            ESM log Size is full ---- How to Clear If your getting the below error in event viewer you can follow the below steps and solve it. Generally when we open Dell open manage console, suddenly we see that Hardware log status is showing critical and event logs are filling saying ESM log is full... We need to clear the ESM logs regularly before it reaches 100%. However please follow the below command and procedure before clearing the logs. Open Dell Manage console, go to logs tab. Then select ESM logs, you will see an export option. Export the logs and save it on local drive for future use. Now open command prompt and Runas administrator. Type omconfig system esmlog action=clear Done, ...

The system cannot log you on due to the following error: The RPC server is unavailable

IF your login to windows 2003 and your getting the below error then do the below steps and you can login to the PC. login to any server in the same subnet. open CMD in elevated permission open registry editor go to File---------->connect to network registry type the effected server name and open it go to the below location and create a new DWORD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server Create a new key selecting Dword and name it as IgnoreRegUserConfigErrors now double click it and give a value as 1. after that do the RDP and it will work.
  Remove "Open in new window" option from Windows Explorer right-click menu Hi Guys today we will see how to block the "Open in New Windows" tab in the file explorer menu. Please see the below screenshot which is showed below. Create the appropriate REG file(s) using this code and then run them: ADD 'Open in a New Window' Option Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\opennewwindow] "MUIVerb"="@shell32.dll,-8517" "MultiSelectModel"="Document" "OnlyInBrowserWindow"="" "LaunchExplorerFlags"=dword:00000001 [HKEY_CLASSES_ROOT\Folder\shell\opennewwindow\command] "DelegateExecute"="{11dbb47c-a525-400b-9e80-a54615a090c0}" REMOVE 'Open in a New Window' Option Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\Folder\shell\opennewwindow] "MUIVerb"="@shell32.dll,-8517" "MultiSelectModel"="Document...