|  | 
| <# : @powershell  -ex bypass -c "icm ([scriptblock]::Create((gc '%~f0' -Raw -Encoding UTF8)))"
 exit
 #>
 #-WindowStyle Hidden
 #[Ps1 To Exe]
 Write-Host -ForegroundColor White ('powershell命令_hash快速txt去重')
 
 
 function 排除 ($文本, $规则) {
 
 
 $文本 | Select-String -Pattern $规则 -NotMatch #排除路径
 }
 function 保留  ($文本, $规则) {
 $文本 | Select-String -Pattern $规则
 }
 
 
 function 正则替换 ($d, $a, $c) {
 $d -replace ($a, $c) #删除盘符
 }
 function hash去重 ($数组) {
 $set = [System.Collections.Generic.HashSet[string]]@($数组)
 $set -join "`r`n"
 }
 
 
 function 等待($毫秒) { Start-Sleep -Milliseconds $毫秒 }
 function 显示($提示, $c) {
 $a = -Join ($提示, $c)
 Write-Host -ForegroundColor White ($a)
 }
 function 退出 { exit }
 function 结束进程($进程名) { Stop-Process -Name $进程名 }
 function 新建txt($路径, $文本) {
 Set-Content  -Path $路径 -Value $文本
 }
 $start = Get-Date #开始计时
 
 
 $正则列表 = gc "WinSxS_wimlib格式列表.txt" #WinSxS.txt
 $files = Get-Childitem -Recurse -Include 'too.txt' #X:\Windows.txt
 $保存文件名= "处理完成.txt"
 $正则列表 = $正则列表.replace("\","\\")
 foreach ($file in $files) {  #遍历文件
 $line = GC $files -ReadCount 0
 $line =$line| Select-String -Pattern ($正则列表)
 }
 
 
 新建txt($保存文件名) $line
 $end = Get-Date #结束计时
 $max= ($end - $start).TotalSeconds
 显示 ('时间: ' + $max + '秒'  ) #计算时间差
 显示('执行完成,请查看WinSxS_wimlib格式列表.txt')
 显示('WinSxS.txt_处理为wimlib格式列表_ps命令_无忧论坛.ps1.cmd')
 显示('15秒自动退出')
 等待(15000)
 退出
 
 
 
 | 
 |