IT漫步

技术生活札记©Yaohui

[Powershell] Create folder, copy file and verify file hash, regex usage

Method #1: $hashPattern = "^MD5\s+(\w+)\s+"; $sourceFile = "C:\temp\6372241e-591e-4063-b15d-8aa34ae1ac63.txt"; $destFolder = "C:\app\social space\data\scp"; $destFileName = "test.txt"; $destFile = Join-Path -Path $destFolder -ChildPath $destFileName; New-Item -ItemType Directory -Force -Path $destFolder | Out-Null; Copy-Item $sourceFile -Destination $destFile -Force | Out-Null; Get-FileHash $destFile -Algorithm MD5 | Out-String -Stream | Select-String -Pattern $hashPattern | % {$_.matches.Groups[1]} | % {$_.Value}; Key …


Proudly powered by WordPress