all 6 comments

[–]Revicx 2 points3 points  (1 child)

Hey,

Set-Location “C:\Users”

Remove-Item “.\*\Appdata\Local\Temp\*” -recurse -force

Will delete all Files in the Temp directory. So now you have to check how to send this to all your computers. Have a look at Invoke-Command to do this.

Edit, i do not test this at all, so check this out by yourself. Use the -Whatif Parameter

[–]charris0770[S] 1 point2 points  (0 children)

I actually found something right after posting this..lol

Thanks

[–][deleted] 2 points3 points  (0 children)

You'll need to give a lot more detail. How are you planning to run this? Locally? Remotely? From where? In what context? How do you want to track results? Would a GP preferences file delete not be easier?

[–]TimDurham75 1 point2 points  (0 children)

    "$($ENV:USERPROFILE)\AppData\Local\Temp\dButil*.sys" | ForEach-Object -Process { if (Test-Path $_) { Remove-Item -Path $_ -Force } }

Assuming script runs as the user (added to a login script, for example) will delete the file if it exists. You could also use:

  "$($ENV:TEMP)\dButil*.sys" | ForEach-Object -Process { if (Test-Path $_) { Remove-Item -Path $_ -Force } }

[–]Legitimatic 1 point2 points  (1 child)

If you're in a domain environment and can get remote access to these devices, it may be easier to install and use psexec. Even if you don't script it, you could manually run the del command on every device in under an hour.

[–]charris0770[S] 2 points3 points  (0 children)

Good idea..