August 9, 2022 at 8:41 pm
Hi Team - I have the below PowerShell script which is working for me to capture the results for one set of backup file but my requirement is to copy 10 or more backups files parallelly to a shared location and capture the result and append the result to the result_log .CSV format....with the following result set....
Can someone help me modify the script to capture these results plz ? I am a newbie to PowerShell
DBName BackupPathAndName BackupSizeMB CopyStartDateTime CopyEndDateTime DurationSeconds
--Working Powershell Script
Start-Transcript
$Password = ConvertTo-SecureString -AsPlainText -Force -String "Password"
$User = "UserName"
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$password
$item = get-item 'C:\Temp\BackupFileName.bak'
$time=Measure-Command -Expression {Copy-Item -literalpath 'C:\Temp\BackupFileName.bak' '\\IP\Shared\TEST\BackupFileName.bak'}
$TransferRate = ($item.length/1024/1024) / $time.TotalSeconds
write-host "$TransferRate MB/Sec"
$result = New-Object -TypeName psobject -Property @{
Source = $item.fullname
TimeTaken = $time.TotalSeconds
TransferRateMBs = $TransferRate
}
$result|Export-Csv 'C:\temp\Result_Log.CSV' -Force -Append -NoTypeInformation
Stop-Transcript
Regards,
SQLisAwe5oMe.
August 10, 2022 at 1:10 am
I'm no help here but that "password in text" stuff is one of the reasons I hate it. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
August 10, 2022 at 6:20 pm
I would recommend using Robocopy - it can be called from a PS script and there are many possible parameters to fit almost any requirement.
The output from Robocopy also provides all of the information you need to track here - and that output can be redirected to another file and/or the console.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 22, 2022 at 3:51 pm
Thanks Jeffrey, do you have a link you can refer me to?
Regards,
SQLisAwe5oMe.
August 22, 2022 at 4:56 pm
Thanks Jeffrey, do you have a link you can refer me to?
It's part of the windows operating system. Just Google it.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply