Jac*_*son 3 powershell getdate
为什么这不起作用?:
Copy-Item "C:\Logs\VPNLog.txt" "C:\Backup\VPNLog$(Get-Date -UFormat %d-%m-%Y-%R).txt"
Run Code Online (Sandbox Code Playgroud)
错误信息:
Copy-Item : The given path's format is not supported.
根据记录,这有效:
Copy-Item "C:\Logs\VPNLog.txt" "C:\Backup\VPNLog.txt"
Run Code Online (Sandbox Code Playgroud)
正在%R输出用冒号格式化的时间,并且文件名中不能包含冒号。要看到这一点,只需运行get-date -uformat %d-%m-%Y-%R
要获取不带冒号的小时、分钟和秒,您需要使用类似于以下内容的 get-date 命令:
get-date -uformat %d-%m-%Y-%H.%M.%S
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14242 次 |
| 最近记录: |