-1

Если я использую Get-ChildItem для поиска по всему C:\, файлы не найдены, но если я ограничу его C:\ProgramData\, файл будет найден. Зачем?

Укороченная версия

Get-ChildItem C:\ -Recurse -Filter curl-ca-bundle.crt

(Ничего не найдено)

Get-ChildItem C:\ProgramData\ -Recurse -Filter curl-ca-bundle.crt

(находит C:\ProgramData\chocolatey\lib\curl\tools\curl-7.63.0-win64-mingw\bin\curl-ca-bundle.crt)

Полная версия

**********************
Windows PowerShell transcript start
Start time: 20181213133922
Username: ████████████████████████
RunAs User: ████████████████████████
Configuration Name: 
Machine: ████████████████████████ (Microsoft Windows NT 10.0.17134.0)
Host Application: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -nopro
Process ID: 16060
PSVersion: 5.1.17134.407
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17134.407
BuildVersion: 10.0.17134.407
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is find-curl-certs.log
PS C:\Users\brianl> Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
Get-ChildItem : Access to the path 'C:\Windows\CCM\ScriptStore' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\CCM\ScriptStore:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\Windows\CCM\ScriptStore' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\CCM\ScriptStore:String) [Get-ChildItem], Una
uthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\Windows\CSC' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\CSC:String) [Get-ChildItem], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\Windows\CSC' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\CSC:String) [Get-ChildItem], UnauthorizedAcc
essException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\Windows\System32\LogFiles\WMI\RtBackup' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\Syst...es\WMI\RtBackup:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\Windows\System32\LogFiles\WMI\RtBackup' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ -Filter curl-ca-bundle.crt -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\Windows\Syst...es\WMI\RtBackup:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

PS C:\Users\brianl> Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recurse


    Directory: C:\ProgramData\chocolatey\lib\curl\tools\curl-7.63.0-win64-mingw\bin


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       12/13/2018     12:07         207949 curl-ca-bundle.crt
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Diagnosis\FeedbackHub' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...sis\FeedbackHub:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Diagnosis\FeedbackHub' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...sis\FeedbackHub:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Diagnosis\TenantStorage\P-ARIA' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...tStorage\P-ARIA:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Diagnosis\TenantStorage\P-ARIA' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...tStorage\P-ARIA:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows\SystemData' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...dows\SystemData:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows\SystemData' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...dows\SystemData:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cache' is 
denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Cache:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat
Protection\Cache' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Cache:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Cyber' is 
denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Cyber:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat
Protection\Cyber' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Cyber:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd

Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Trace' is 
denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Trace:String) [Get-ChildItem], 
UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemCommand
Get-ChildItem : Access to the path 'C:\ProgramData\Microsoft\Windows Defender Advanced Threat
Protection\Trace' is denied.
At line:1 char:1
+ Get-ChildItem -Path C:\ProgramData\ -Filter curl-ca-bundle.crt -Recur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\ProgramData\...rotection\Trace:String) [Get-ChildIte
m], UnauthorizedAccessException
    + FullyQualifiedErrorId : DirUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetChildItemComma
nd



PS C:\Users\brianl> $PSDefaultParameterValues
PS C:\Users\brianl> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.407
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.407
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\Users\brianl> (Get-Command Get-ChildItem).Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Compu...


PS C:\Users\brianl> (Get-PSProvider FileSystem).ImplementingType.Assembly.FullName
System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
PS C:\Users\brianl> Stop-Transcript
**********************
Windows PowerShell transcript end
End time: 20181213135005
**********************

1 ответ1

2
  • Для принудительного погружения во все подкаталоги добавьте параметр -Force
  • Для подавления ошибок / предотвращения взлома добавьте -ErrorAction SilentlyContinue или short -EA 0

Get-ChildItem C:\ -Filter curl-ca-bundle.crt -Recurse -Force -EA 0

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .