I'm currently working on a SQL Server JOB file that contains the following code
@active_end_date = 99991231,
@active_start_time = 0,
@active_end_time = 235959,
@schedule_uid = N'59cbfb7d-67c7-495c-810d-0ca7a6357f9c'
IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
I'm using PowerShell to remove the @schedule_uid
with this code:
$orgineel_localfolder = "C:\Users\Desktop\Jobs_from_Server\aangepast"
$stringtorremove = '@schedule_uid='
$files = Get-ChildItem $orgineel_localfolder *.sql
ForEach ($file in $files)
{
$linenumber = Select-String $file -pattern $stringtorremove
$removecomma = $linenumber -replace",",""
$fileName = "C:\Users\EX27740\Desktop\Jobs_from_Server\Orgineel\" + $file.Name.replace("_Orgineel","_nieuwe") # Vervangt alle Orgineel maar niet erg script blijft goed
(Get-Content $file.fullname) -notmatch $stringtorremove | Out-File $fileName
}
My problem is that in the previous line @active_end_time = 235959,
. Because the data in this line is not always @active_end_time
, I want to get the line number of this line by retrieving the line number of the line that I will remove -1.
How can I do this?