6
2
Im trying to run the following code as a powershell script,but I cant get it to work. 1st,the following works with one -Include
item but I cant seem to get it to work with multiple ones. 2nd, the -Exclude
perimeter doesn't seem to work. I still get files from the C:\Windows and C:\Program Files directorys .
$Include = "*.zip","*.rar","*.tar","*.7zip"
$exclude = "C:\Windows","C:\Program Files"
Get-ChildItem "C:\" -Include $Include -Exclude $Exclude -Recurse -Force -ErrorAction silentlycontinue | Select-Object -ExpandProperty FullName
Note: The purpose of this script is to find all compressed files on the system. I know this is probably really simple but I just cant seem to get it to work.
Once I took out the
-Force
and the-EA 0
it worked. I don't know why? Thanks. – securityghost – 2017-03-21T02:33:11.850Sorry for that, PowerShell version differences. Both are supported in higher releases.
-EA 0
is just an abreviation for-ErrorAction silentlycontinue
– LotPings – 2017-03-21T06:03:30.367