【发布时间】:2022-10-17 07:45:37
【问题描述】:
我有以下脚本来递归复制数据并创建目标的日志文件,请提供帮助,我想在复制每个文件后暂停 10 秒,以便每个文件分配一个不同的创建时间戳。
$Logfile ='File_detaisl.csv'
$SourcePath = Read-Host 'Enter the full path containing the files to copy'
""
""
$TargetPath = Read-Host 'Enter the destination full path to copy the files'
""
#$str1FileName = "File_Details.csv"
Copy-Item -Path $SourcePath -Destination $TargetPath -recurse -Force
Get-ChildItem -Path $TargetPath -Recurse -Force -File | Select-Object Name,DirectoryName,Length,CreationTime,LastWriteTime,@{N='MD5 Hash';E={(Get-FileHash -Algorithm MD5 $_.FullName).Hash}},@{N='SHA-1 Hash';E={(Get-FileHash -Algorithm SHA1 $_.FullName).Hash}} | Sort-Object -Property Name,DirectoryName | Export-Csv -Path $TargetPath$Logfile
【问题讨论】:
标签: powershell copy-item