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

Vm backup failling with snapshot error (156)An error occurred while saving the snapshot: Failed to quiesce the virtual machine.

  Hi Everyone, I am here back with another issue. If anyone is getting error taking backup snapshot of a virtual machine and getting the below error. Vm backup failling with snapshot error (156)An error occurred while saving the snapshot: Failed to quiesce the virtual machine. Apr 28, 2021 2:22:55 AM - Critical bpbrm (pid=15849) from client XXXXX: FTL - vSphere_freeze: Snapshot task for virtual machine XXX-YYY (/vmmor/vm-341) failed, 0 retries remaining, error type: 263, error message: An error occurred while saving the snapshot: Failed to quiesce the virtual machine.. Apr 28, 2021 2:23:08 AM - Critical bpbrm (pid=15849) from client XXXX: FTL - vfm_freeze: method: VMware_v2, type: FIM, function:...

System Volume Information is taking more space

On one of the servers (running Windows Server 2012 R2) I faced a problem with the lack of free space on a system drive. I have cleared all resource-consuming locations ( WinSxS , TEMP directories, user profiles,  outdated updates , etc.), but it didn’t have any evident effect. At last, I have found that a large part of a system disk has been occupied by  System Volume Information  folder. Let’s consider why we need System Volume Information folder in Windows systems, what is stored in it and how to clean up it. Note . The instructions given in this article are applicable to other Windows versions as well:   Windows 10, Windows 7, Windows 8, Windows 2008 R2, Windows 2012 / 2012 R2. System Volume Information  folder is in the root of each disk. System data related to system recovery and Shadow Copy Service are stored in it. By default it is hidden and only the SYSTEM has access to it. Even the administrator cannot open it and look through the contents of th...