Author Posts

June 27, 2015 at 5:39 pm

So I don't have to keep pulling from a txt file that I create by export servers since I want this to run every 30 days.

$computers = Get-ADComputer – SearchBase 'OU=Test,DC=Test,DC=COM' -filter * | select -expand name
ForEach($computers in $computers)
{
Remove-Item c:\windows\ccmcache\* -Force -recure

June 27, 2015 at 8:55 pm

I guess you want to do something along the lines of

June 28, 2015 at 6:39 am

Thank you that worked. I so appreciate the help I was trying all different ways and none was working.

June 28, 2015 at 7:03 am

The C$ is missing from the path. You will need to possibly escape the $ with a backtick (`) like \C`$\ or I prefer a string format:

$computers = Get-ADComputer –SearchBase 'OU=Test,DC=Test,DC=COM' -filter * 
 ForEach($computer in $computers) {
    $path = "\\{0}\c$\windows\ccmcache\*" -f $computer.name
    Remove-Item $path -Force -recure
 }

June 28, 2015 at 1:15 pm

yep I added that to the path and it's working for me now, thanks