从robocopy结果获取$ LastExitCode并输出到文件

时间:2018-06-06 09:33:31

标签: powershell logging output robocopy

如何从PowerShell中获取robocopy $source = "E:\LOShare\process\data\attachments" $day = (Get-Date).Day "Day: " + $day $month = (Get-Date).Month "Month: " + $month $year = (Get-Date).Year "Year: " + $year $destination = "F:\Attachments\" + $year + "\" + $month "Destination: " + $destination $parameters = "/mov /minage:" + $year + $month + $day + "/s" $rc = Start-Process robocopy $source $destination $parameters -Wait if ($LastExitCode -lt 8) { $outputFileSuccess = "F:\Attachments\RobocopySuccess" + $day + $month + $year + ".txt" Write-Host "Robocopy succeeded" GetProcess | robocopy Out-File -FilePath $outputFileSuccess } else { $outputFileError = "F:\Attachments\RobocopyError" + $day + $month + $year + ".txt" Write-Host "Robocopy failed with exit code:" $LastExitCode GetProcess | robocopy Out-File -FilePath $outputFileError } 结果并将其输出到文件?

这就是我的尝试:

conda install -c anaconda glib

0 个答案:

没有答案