bibi92
asked on
write-output without carrier return
Hello,
How can I modify the following script and write-output without carrier return of jobname is long :
Regards
How can I modify the following script and write-output without carrier return of jobname is long :
if ($arg2 -eq "JOBS") {
$LIST_JOBS = (& $OSQL_CMD -E -S $server -h -1 -b -W -Q "set nocount on; SELECT DISTINCT REPLACE(REPLACE(REPLACE(name,'[',''),']',''),' ', '') FROM msdb..sysjobs where name not like 'CDW%'")
# Check Code Error
if ($LASTEXITCODE -ne 0) { $st = 1 }
$nb_jobs = @($LIST_JOBS).count
for ($i = 0; $i -lt $nb_jobs; $i++) {
if ($nb_jobs -gt 1) {
$array_str = $LIST_JOBS[$i].Split("")
$JOBNAME = $array_str[0].Trim()
}
else {
$JOBNAME = $LIST_JOBS.Trim()
}
if ($CLUSSVC -eq $null -and $INST -ne $LIST_INST[-1]) {
$line_JOB = " { `"{#DBHOST}`":`"" + $HOSTNAME + "`" , `"{#INSTANCE}`":`"" + $INST_NAME + "`" , `"{#JOB}`":`"" + $JOBNAME + "`"},"
}
else {
$line_JOB = " { `"{#DBHOST}`":`"" + "(" + $HOSTNAME + ")" + $SER_NAME + "`" ,`"{#INSTANCE}`":`"" + $INST_NAME + "`" , `"{#JOB}`":`"" + $JOBNAME + "`"}"
}
if ($CLUSSVC -eq $null -and $INST -eq $LIST_INST[-1]) {
$line_JOB = " { `"{#DBHOST}`":`"" + $HOSTNAME + "`" , `"{#INSTANCE}`":`"" + $INST_NAME + "`" , `"{#JOB}`":`"" + $JOBNAME+ "`"}"
if ($i -lt $nb_jobs-1 -or $i -lt $nb_jobs-1) { $line_JOB += ',' }
}
Write-Output $line_JOB
}
}
}
}
}
ThanksRegards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.