我正在使用 ROBOCOPY 创建目录的镜像备份,备份到可移动 SSD。复制已执行,但我想保留以下日志:仅有的每次运行脚本时都会显示结果。如下面的结果。我可以创建日志,但它包含整个脚本结果“7000+”行。我尝试使用 /tee 和 /ndl 开关,但它们似乎没有任何明显的效果。
#Script Mirrors the Network Directory for collected user manuals
#Logs Robocopy Results to a log file
$Time = Get-Date #variable for the current date string
$Logfile = [string] 'c:\Script\BackupManuals.log' #variable Log File Path - You need to create the .txt file first
Add-Type -AssemblyName PresentationFramework #Loads the framework for the message box if needed
ROBOCOPY "\\server-fs-03\Groups\Automation\Support\Master Product Manuals" "V:\Master Product Manuals" /MIR /COPY:DATSO /log+:"c:\Script\BackupManuals.log" /tee /ndl
#$Robo_results = $Robo_test -match '^(?= *?\b(Total|Dirs|Files)\b)((?! Files).)*$'
Write-Output "$Time $robo_results" #Command Line output for Powershell Visual display - optional
#pause #for testing to visually see output
答案1
您还需要使用 /nfl 开关。
/nfl Specifies that file names are not to be logged.