Posts

Showing posts from 2025

AG SECONDARY DATABASE "Synchronizing" Query

The query below will tell us how much of the REDO log needs to harden in the secondry replica of secondary database. Run the query in SECONDARY REPLICA. If the "redo_queue_size" in KB value reducing means the database soon will come into "Synchronized"state have patience and wait for it. select is_primary_replica, synchronization_state_desc, is_commit_participant, synchronization_health_desc, redo_queue_size from  sys.dm_hadr_database_replica_ states

Get-DbaAgentJob,Get-dbaAgentJobStep,dbatools.

Image
This command I have written to get only "@Directory" value alone and want to update it with a new value. However updating it with a new value not handled yet on this. As the command is straight forward with which we can update(Set-DbaAgentJobStep) .The challenge here how to extract "@Directory" value alone and how to change it. $sever = "MAPS\PROD" $newpath = 'D:\BACKUPS' $job = Get-DbaAgentJob ` -SqlInstance $sever ` -Verbose | Where-Object { $_ .Name -like '*DatabaseBackup - USER_DATABASES - FULL*' }| Select-Object Name $directory = Get-DbaAgentJobStep ` -SqlInstance $sever ` -Job $job .Name ` -Verbose| Select-Object -ExpandProperty Command $reqstring = ( $directory | Select-String -Pattern "@Directory\s*=\s*'([^']*)" -AllMatches).Matches.Groups[1].value $directory .Replace( $reqstring , $newpath ) The query below will update "@Directory" value in all the requird jobs at a time. $server =...