Ccleaner

Hey Everyone,

I am new to Powershell somewhat. Anyone have codes to download Ccleaner onto a computer automatically and run lets say once a month, or week silently in the background?

Thanks

You mean, Task Scheduler?

I know how to do that, but I wanted to see if I can run Ccleaner automatically with a PS script.

I have around 50 users I am working with so I’d rather not push TS out to all of them individually.

Anyone know of a CC script to run in background?

Like Don mentioned above, the answer is Task Scheduler.

My understanding is, you want to:

1- Download and install CCleaner
2- Run CCleaner

Well, the download and install can be done with a PS Script, but running it every month, that’s a job for Task Scheduler.

You can find info about CCleaner command line here

This is great for deploying to 1 or 2 users, but what about 50+?

There has to be an invoke-command script for multiple installs.

Rocky

What difference 2, 50 or 500 makes? an invoke-command will be needed.

It seems you need to read a little bit more about PowerShell Remoting.

Just to clarify want you want/can do:

Powershell can do an invoke-command for you (loop through all the pc you want/need)
Use it to start the installation:

ccsetup.exe /S

After that you need to create a scheduled task (that can be done in powershell) if you want it to run daily:

CCleaner.exe /AUTO

You can create

Hey Everyone,

I made some progress but I am still getting “Access is denied” error codes coming back from computers. Anyone have suggestions? The underlines have script in them I have just removed for security purposes.

Rocky

foreach ($pc in (get-adcomputer -searchbase “OU=Laptops,OU=Computers,OU=, OU=NA, OU=Regions, DC=, DC=, DC=" -filter *|where{$.enabled}).Name) {
$pc
invoke-command -ComputerName $pc -scriptblock {Start-Process -FilePath "\
___\temp$\CC\CCleaner64.exe” -ArgumentList “/CLEANER /AUTO”}

}

CCleaner was recently hacked so I’d be cautious of just downloading and installing it.
CCleaner hack affects 2.27 million computers

The versions that were affected are CCleaner v5.33.6162 or CCleaner Cloud v1.07.3191 for 32-bit Windows PCs.
If you update to latest version you will be fine.

Just a theory, but I know that PowerShell remoting won’t let you do multiple hops. That is, you can’t remote to one machine and then remote and execute code on a third machine. You’ll get “access denied” errors. The fact that you’re remoting to one machine and trying to launch an executable that resides a network share may be the problem.

Again, this is just a theory. I could be completely wrong on this.

This is not correct in our case. We aren’t hopping from one then to another. You are running on one, closing, running on the next. One at a time.

The second hop isn’t when you move to the next computer. It’s when you try to run the executable that’s hosted on a remote network share. To test my theory copy the CCleaner.exe executable to a local directory on a target machine “C:\Temp” for instance, then modify your script to look for it there. If the script runs without issue then that suggests it’s a double-hop issue. If you still get “Access Denied” then it’s something else.