PowerShell Script: Database Health Check Email PowerShell Script: Database Health Check Email # Mail Server information $SMTPServer = "smtp.gmail.com" $SMTPPort = "587" $UserName = "ramesh30.m@gmail.com" $Password = "Gmail application security password here" # Adding email addresses $to = "ramesh30.m@gmail.com" $from = "ramesh30.m@gmail.com" $cc = "rameshmamillapalli@outlook.com" $subject = "Database Report | $(Get-Date)" # HTML styling for report $head = @" <style> h1 { background-color: aqua; display: block; width: fit-content; margin-left:auto; margin-right:auto; font-size: 15px; } h2 { background-color: aqua; display: block; width: fit-content; margin-left:auto; margin-right:auto; padding:5px; } table { border-width:1px; border-style:double; border-color:beige; border-collapse:collapse; border:1px solid black; padding:5px 10px; margin-left:auto;...
Posts
Showing posts from 2025
Activate "Windows Server 2016 DataCenter Evaluation Edition"
- Get link
- X
- Other Apps

AG SECONDARY DATABASE "Synchronizing" Query
- Get link
- X
- Other Apps
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.
- Get link
- X
- Other Apps

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 =...