Posts

Showing posts from 2025

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