You can update your code in PowerShell
something like this that will write a log
for you once the Rebuild Link Databases
task will be finished for all the databases. Her is the code snippets.
foreach($database in Get-Database) {
if(!$database.ReadOnly) {
Write-Log "Rebuilding the $($database) link database."
$time = Measure-Command {
[Sitecore.Globals]::LinkDatabase.Rebuild($database)
}
Write-Log "Completed rebuilding the $($database) link database in $($time.TotalSeconds) seconds."
}
}
It will create a log file in your App_Data
folder.

And the logs will be written something like this.
ManagedPoolThread #17 13:42:12 INFO Rebuilding the master link database.
ManagedPoolThread #17 13:42:49 INFO Completed rebuilding the master link database in 37.7867178 seconds.
ManagedPoolThread #17 13:42:49 INFO Rebuilding the web link database.
ManagedPoolThread #17 13:43:28 INFO Completed rebuilding the web link database in 38.3885773 seconds.
ManagedPoolThread #17 13:43:28 INFO Rebuilding the core link database.
ManagedPoolThread #17 13:44:26 INFO Completed rebuilding the core link database in 58.6195402 seconds.
I think this way you can make sure that your Rebuild Link Databases
task has been successfully completed.
Hope this will help.
[Sitecore.Globals]::LinkDatabase.Rebuild($database)
command to rebuild your database? Can you add some code snippets?