Delete all .ica files

I tried several different ways and still the same results as it doesn't work.

remove-item .\*\appdata\local\temp\* -Include *.ica

I want it to delete all .ica files in the temp users folder.

+4
source share
3 answers

It looks like you are looking for a temporary user folder. If you are looking for this, you can find it with $path = $env:tempUse this for the $ path that @kekimian used.

The finished product will look something like this:

$path = $env:temp
Get-ChildItem -path $path -Filter "*.ica" -Force -Recurse | Remove-Item -Force -Confirm:$False
+3
source

Try the following:

$path = path to the folder
Get-ChildItem -path -Filter "*.ica" |  where { ! $_.PSIsContainer } | Remove-Item -Force -Confirm:$true
+2
source

, , , remove-item:

Get-ChildItem "c:\users\$username\appdata\local\temp\*.ica" -Force -Recurse | Remove-Item -Confirm:True

- -

Get-ChildItem -Path "C:\Users\$username\appdata\local\temp" -Include '.ica' -Force -Recurse | Remove-Item -Confirm:True

, -Force Get-ChildItem, . , .

Edit:

foreach ($user in (Get-ChildItem -Directory C:\Users).name) { <#do stuff#> }

In addition, $ENV:TempPowerShell is equivalent %TEMP%. There are many other environment variables contained in $ENV:.

Or if you need to do this for all users:

Get-ChildItem -Path "C:\Users\" -Include '.ica' -Force -Recurse | Remove-Item -Confirm:True

+2
source

Source: https://habr.com/ru/post/1614334/


All Articles