Get-ChildItem -Path "$Loc" -Recurse -Include *.cfg,*.bat,*.xml,*.properties,*.ini,*.config -Exclude *.dll,*.log,*.exe,*log*.txt,*.tmp,*.mdb,*.mdf,*.edb,*.dat,*.zip,*.pem,*.ldf |
Select-String -Pattern "password=" |
Select-String -Pattern "pass=" |
Select-String -Pattern "passwd=" |
Select-String -Pattern "passphrase=" |
Select-String -Pattern "pass=" |
Select-String -Pattern "pwd=" |
Select-String -Pattern "psw=" |
Select-String -Pattern "<password>" |
Select-Object Path, Filename, Pattern, LineNumber, Line
我想在D驅動器中存在的所有文件中搜索上述模式。處理它需要很多時間。是否有可能通過優化上面的查詢來減少所涉及的時間?查詢需要很多時間來處理單行命令需要幫助來優化它
您應該將通過'|'分隔的模式組合在一個模式字符串中。但是,如果驅動器D有很多文件,那麼Get-ChildItem本身就會很慢,除了直接讀取驅動器的MFT或USN日誌或者可能使用[Everything(http://www.voidtools.com/) )的API。 – wOxxOm