Powershell 复制项复制文件夹并更改时间戳(不保留时间戳)
我当前正在创建Powershell脚本以将文件夹复制到远程服务器 我使用copy item cmdlet更改文件夹的时间戳 有没有办法复制文件夹并保留文件夹的时间戳Powershell 复制项复制文件夹并更改时间戳(不保留时间戳),powershell,powershell-remoting,copy-item,Powershell,Powershell Remoting,Copy Item,我当前正在创建Powershell脚本以将文件夹复制到远程服务器 我使用copy item cmdlet更改文件夹的时间戳 有没有办法复制文件夹并保留文件夹的时间戳 提前感谢复制目录时,只需在不同位置创建同名的新目录即可 param( [System.IO.DirectoryInfo]$sourecDir = "D:\tmp\001", [System.IO.DirectoryInfo]$destDir = "D:\tmp\002" )
提前感谢复制目录时,只需在不同位置创建同名的新目录即可
param(
[System.IO.DirectoryInfo]$sourecDir = "D:\tmp\001",
[System.IO.DirectoryInfo]$destDir = "D:\tmp\002"
)
[System.IO.Directory]::CreateDirectory("D:\tmp\002")
$destDir.CreationTime = $sourecDir.CreationTime
文件夹的时间戳通常与其中的最新文件相同。因此,如果你想保持一个特定的日期,你应该操纵文件夹中最新文件的日期。