Im trying to run a recursive search through all of C Drive, but wish to exclude Windows & Program Files.
Confused as to why this doesn't work.
$b = if(Get-ChildItem -Path C:\ -Recurse -Force -filter *.exe -Exclude Users,Windows | ? {$_.Name -eq 'firefox.exe'})
{
return $true
}
else {
return $false
}
$b
I know it isn't working as I get access denied errors due to the drive permissions.
Get-ChildItem : Access to the path 'C:\Windows\ccmsetup' is denied.
At line:1 char:9
+ $b = if(Get-ChildItem -Path C:\ -Recurse -Force -filter *.exe -Exclud ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Windows\ccmsetup:String) [Get-ChildItem], UnauthorizedAccessException
+ FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand