Check the integrity of the ccmcache with PowerShell
The script below compares the WMI entries in CacheInfoEx with the folders in c:\windows\ccmcache and vice versa. Any inconsistencies will be listed in red (an entry in WMI doesn’t match the folder) or yellow (a folder exists for which an entry in WMI is missing). It may help you to find out why the size of your ccmcache folder exceeds the limit or to prepare a cleanup of orphaned folders. With a slight modification, you can use the script in a Compliance Item or run it by the console feature Script of the ConfigMgr. You just have to remove all Write-Host lines and create a summary based on the counters $WMIInconsistancies and $orphanedFolderCount.
#This code is provided AS-IS and without any warrenties
$Cache = get-wmiobject -query "SELECT * FROM CacheInfoEx" -namespace "ROOT\ccm\SoftMgmtAgent"
$WMIInconsistancies = 0;
foreach($item in $Cache)
{
$foldersize = [math]::truncate(((Get-ChildItem -path $item.Location -recurse | Measure-Object -property length -sum ).sum)/1024)
$outstring = $item.Location + ' ' + $item.ContentSize + ' ' + $foldersize
if ($foldersize -eq $item.ContentSize){
Write-Host $outstring -BackgroundColor DarkGreen
}
else{
Write-Host $outstring -BackgroundColor DarkRed
$WMIInconsistancies++
}
}
$folders = Get-ChildItem -Path C:\Windows\ccmcache | ?{ $_.PSIsContainer } | Select-Object FullName
$OrphanedFolderCount = 0
foreach($folder in $folders){
$OrphanedFolder = $true
foreach($item in $Cache){
if($item.Location.ToLower() -eq $folder.FullName.ToLower()){
$OrphanedFolder = $false
break;
}
}
if($OrphanedFolder -eq $true){
Write-Host $folder.FullName ' is not in WMI. You may delete it.' -BackgroundColor DarkYellow
$OrphanedFolderCount++
}
}
if($orphanedFolderCount -gt 0 -or $WMIInconsistancies -gt 0)
{
Write-Host('Inconsistencies found') -BackgroundColor DarkYellow
}
Troubleshoot failing Windows 10 Feature Updates
Search in C:\$WINDOWS.~BT for *.logs (the folder is hidden)
Copy the setupact.log and setuperr.log (you probably won’t be able to open them from their location).
Check the setupact.log for errors. In case of hanging installations, check the last lines.
Search for compatdata*.xml in C:\$WINDOWS.~BT. Usually the newest xml is most relevant.
Look for blocking entries (BlockMigration=TRUE):
Run pnputil /enum-devices to get device names for each inf.
Find the device in Device Manager and update the driver or try disabling the device.
Measure ConfigMgr collection update time
Anybody who worked with ConfigMgr for longer knows that slow collection updates can be a real nuisance. You add a machine to a collection and sometimes it takes ages until it appears. You can’t even say exactly when it showed up since the hourglass doesn’t disappear until you update the display. So how long did it really take? To be able to measure the time, I wrote a script that creates a collection, adds a machine to it and then checks every 2 seconds if it is already there. Once it is, it deletes the collection again and displays the time.
To identify performance bottlenecks you may need to run this script to different times, under different accounts (RBAC can influence the performance) and from different locations.
#Test the time it takes to create a collection und to add a machine by direct membership
#This script is provided as-is without any warranty
[CmdletBinding()]
Param
(
# TestMachine: Any machine will do - it will just be added to our test collection
[Parameter(mandatory)]
$TestMachine,
# Provider: The provider is usually running on the primary
[Parameter(mandatory)]
$ProviderMachineName,
# SiteCode: The 3-letter sitecode that identifies your environment
[Parameter(mandatory)]
$SiteCode
)
$TestCollectionName = 'TemporaryPerformanceTestCollection'
$stopwatch = [system.diagnostics.stopwatch]::startNew()
machine name
# Customizations
$initParams = @{}
# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams
}
# Connect to the site's drive if it is not already present
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}
# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
$testcoll = New-CMDeviceCollection -LimitingCollectionId 'SMSDM003' -Name $TestCollectionName
$timeout = $false
$count1 = $count2 = 0
while($count1 -le 300)
{
$coll = Get-CMDeviceCollection -Name $TestCollectionName
if($coll -ne $null)
{
Write-Host 'Collection creation succeeded' -BackgroundColor DarkGreen -ForegroundColor White
Try{
Add-CMDeviceCollectionDirectMembershipRule -CollectionId $coll.CollectionID -ResourceId (Get-CMDevice -Name $TestMachine).ResourceID #-Resource $TestMachine #-ErrorAction Stop
}
Catch
{
Write-Host 'Failed to add $TestMachine to TemporaryPerformanceTestCollection. Please check that the machine exists and that the collection has been created.' -BackgroundColor DarkRed -ForegroundColor Yellow
Exit
}
while($count2 -le 300)
{
Try{
$machine = Get-CMCollectionMember -Name $TestMachine -CollectionName 'TemporaryPerformanceTestCollection'
}
Catch{
Write-Host 'Machine not yet found in collection' -BackgroundColor Black -ForegroundColor Yellow
}
if($machine.Name -ne $null){
Write-Host '$TestMachine showed up in Collection' -BackgroundColor DarkGreen -ForegroundColor White
break;
}
else
{
Write-Host 'Machine did not show up yet, sleeping 2 sec before next check' -BackgroundColor Black -ForegroundColor White
Sleep -Seconds 2
}
$count2++;
}
break;
}
else
{
Write-Host 'Collection is not yet there, sleeping 2 sec before next check' -BackgroundColor Black -ForegroundColor White
Sleep -Seconds 2
count1++
}
}
$stopwatch
Write-Host 'Script ran for' $stopwatch.Elapsed.TotalSeconds 'seconds' -BackgroundColor Black -ForegroundColor White
Remove-CMCollection -Name TemporaryPerformanceTestCollection -Force
Set-Location "c:"
9.1 seconds is not a bad value. How long did it run in your environment?