|
AI
- $excludedFolders = "C:\Windows*","C:\Program Files (x86)*","C:\Program Files*","C:\ProgramData*"
- $folders = Get-ChildItem -Path C:\ -Directory -ErrorAction SilentlyContinue | Where-Object {$_.FullName -notmatch ($excludedFolders -join "|")}
- $excelFiles = foreach ($folder in $folders) {
- Get-ChildItem -Path $folder.FullName -Include *.xls,*.xlsm,*.xlsx,*.xlsb -ErrorAction SilentlyContinue
- }
- # 输出结果
- if ($excelFiles) {
- $excelFiles | Select-Object FullName
- } else {
- Write-Host "未找到任何Excel文件。"
- }
复制代码 |
|