Try {
    # setup
    $rootDrive = (get-location).Drive.Name + ":"
    $pathDeployments = Join-Path -Path "$rootDrive" -ChildPath "Deployments"

    $pathVersion = "1.0.0.0"
    $pathInstallSync = "$pathDeployments\Install\Sync\$pathVersion"
    $pathInstallSyncExe = "$pathInstallSync\AAT.Genie.Sync.exe"

    $syncServiceName = "SyncService"

    # boolean
    $isRunning_SyncService = $false

    Write-Host -ForegroundColor yellow "`n--- Sync ---`n"

    If (test-path $pathInstallSync) {
        # check if sync service is installed (stop if running)
        If (Get-Service $syncServiceName -ErrorAction SilentlyContinue) {
            $service = Get-Service -Name $syncServiceName
            If ($service.Status -eq 'Running') {
                Write-Host "Stopping Sync Service..." -NoNewline
                $isRunning_SyncService = $true
                Stop-Service -Name $syncServiceName -Force
                Write-Host "done."
            }
        }
      
        Write-Host "Syncing data from the cloud..." -NoNewline
        Start-Process -FilePath $pathInstallSyncExe -NoNewWindow -Wait
        Write-Host "done."

        # restart sync service
        If ($isRunning_SyncService) {
            Write-Host "Starting Sync Service..." -NoNewline
            Start-Service -Name $syncServiceName
            Write-Host "done."
        }
    }
}
Catch {
    throw $_.Exception.Message
}