Share via

Need Powershell script

TechUST 696 Reputation points
2024-02-14T01:07:25.11+00:00

Hi Techie, I looking for Power shell script, which will perform disk cleanup. Normally i want to do cleanup ccmcache and recycle bin. Please help me with this.

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Other
Microsoft System Center | Other
0 comments No comments

Answer accepted by question author

XinGuo-MSFT 22,271 Reputation points
2024-02-14T02:06:24.7566667+00:00

Hi,

There is a new script available to cleanup SCCM cache files from the client-side:

## Initialize the CCM resource manager com object
[__comobject]$CCMComObject = New-Object -ComObject 'UIResource.UIResourceMgr'
## Get the CacheElementIDs to delete
$CacheInfo = $CCMComObject.GetCacheInfo().GetCacheElements()
## Remove cache items
ForEach ($CacheItem in $CacheInfo) {
    $null = $CCMComObject.GetCacheInfo().DeleteCacheElement([string]$($CacheItem.CacheElementID))
}

## This example doesn't prompt for confirmation to clear the recycle bins.

Clear-RecycleBin -DriveLetter C -Force

Clears the contents of the recycle bin:

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/clear-recyclebin?view=powershell-7.4

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.