Use ffs in Powershell

Discuss new features and functions
Posts: 2
Joined: 3 Jul 2016

oferw3412@gmail.com

Hi folks.
I wrote a script in Powershell that take my backup disk online (It is offline for security reason), than run the ffs_batch and than take the disk offline again.
My problem is that the powershell not aware to the backup operation and it doesnt know when the operation is finish. Is there any way to let tell Powershell when the operation is completed?
I asked microsoft but I was referred to you (in this forum https://social.technet.microsoft.com/Forums/en-US/d97cad8a-d449-447c-b16e-e1448c6a7da6/use-powershell-for-detect-and-close-app-after-completing-backuping-data?forum=winserverpowershell)
Can any one have any idea?

Thanks
User avatar
Posts: 2451
Joined: 22 Aug 2012

Plerry

Perhaps you can split things in two:
1) Have a 1st script that takes your disk online and then runs the ffs_batch.
2) Use the FFS "on completion" synchronization setting (F8) to launch a 2nd script to take the disk offline again
User avatar
Site Admin
Posts: 7211
Joined: 9 Dec 2007

Zenju

Uhm, just wait until the ffs_batch job has finished? (synchronous command invocation)
Posts: 2
Joined: 3 Jul 2016

oferw3412@gmail.com

Thanks Plerry!
This is greate idea.
I will try it...
Posts: 17
Joined: 30 Mar 2011

drivetheory

The cmdlet "Start-Process" that has the "-Wait" paramater.
https://technet.microsoft.com/en-us/library/hh849848.aspx
http://ss64.com/ps/start-process.html
if you need something more robust, tweak the script below to your liking
$ffs = 'C:\FreeFileSync\FreeFileSync.exe'
$path = 'D:\ffs jobs\'
$set1 = 'dataset1.ffs_batch'
$msg = 'msg'
$user = 'Dave'
$sys = '/server:HAL9000'
$status = 'has completed'
$q = '\"'

# start sync
& $ffs $path$set1

# wait
Do {
    $FFSbusy = Get-Process -Name FreeFileSync | Select-Object -ExpandProperty Name
    If ($FFSbusy) {
        Start-Sleep -Seconds 10
    }
} Until (!$FFSbusy)

# execute command afterwards
& $msg $user $sys $q$set1$q $status