At one of my customers I’m part of a project team where we needed to start with a ‘fresh’ set of SCCM logs on the clients because that would make our troubleshooting a bit easier.
So, here’s a handy little script to remove the ConfigMgr client logs from a bunch of servers, which are queried from the Active Directory 🙂
Note that this is purely quick and dirty… there is no error handling or logging whatsoever.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$Servers = Get-ADComputer -Filter {samaccountname -like "SRV-RDS*"} foreach ($Server in $Servers) { if (Test-Connection -ComputerName $Server.Name -Quiet) { invoke-command -ComputerName $Server.Name -ScriptBlock { if (Test-Path -Path 'C:\Windows\CCM') { Get-ChildItem -Path 'C:\Windows\CCM\Logs' -File -Include .log | foreach { Remove-Item $_.FullName -force } } } } } |