Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Who am I ? Expand / Collapse
Author
Message
Posted Wednesday, September 11, 2013 2:08 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 3, 2013 2:05 AM
Points: 2, Visits: 13
Hi,

I run, now, my jobs with steps written in powershell.
I would like to get informations about the current job, the current step, I am running.

I read some topics about token (like $(ESCAPE_NONEJOBID))) but don't succeed to use it in a powershell step.
Is'nt exist more recent method ?
Is there some initialized variables like $host or $myinvocation where I can find these informations ?

Thank you for your help
Post #1493492
Posted Thursday, September 12, 2013 12:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 3, 2013 2:05 AM
Points: 2, Visits: 13
Finally I use 2 tokens.
But I'm not sure it is the best solution.

$myRes = Invoke-Sqlcmd -Query "Select job_id, name From msdb.dbo.sysjobs Where job_id = Convert(Uniqueidentifier,$(ESCAPE_NONE(JOBID)))"
$myJobName = $myRes.name
$myRes = Invoke-Sqlcmd -Query "Select job_id, step_id, step_name From msdb.dbo.sysjobsteps Where job_id = Convert(Uniqueidentifier,$(ESCAPE_NONE(JOBID))) and step_id = $(ESCAPE_NONE(STEPID))"
$myStepName = $myRes.step_name


Ludovic.
Post #1494010
Posted Thursday, September 12, 2013 1:08 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, August 28, 2014 12:47 AM
Points: 7,005, Visits: 8,451
Thank you for the feedback.

Sharing your experiences and fixes will always help others.

I just wonder about the moment a job records it is executing a next step into sysjobhistory.
Will it only record when it receives events for it or at completion time.



Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1494016
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse