cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the status of a schedule

0 Kudos

Hello,

I am trying to get the status of a schedule using powershell. I use this code:

# Loop schedules

$getSchedulesResult.schedules.schedule | Where-Object {$_ -ne $null} | ForEach-Object {

    Write-Output (" - Schedule ID    : " + $_.id)

    Write-Output ("   Schedule name  : " + $_.name)

    Write-Output ("   Schedule format: " + $_.format)

    Write-Output ("   Schedule format: " + $_.format.type)

    Write-Output ("   Schedule status: " + $_.status)

    }

But it returns the following:

- Schedule ID    : 14072

   Schedule name  : RESTful test (13669)

   Schedule format: @{@type=pdf}

   Schedule format:

   Schedule status: @{@id=1; $=Completed}

Can anyone please explain how I can get the status "Completed" and the format "pdf"?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

ted_ueda
Employee
Employee
0 Kudos

Looks like it's returning a Custom Object. Did you try:

$_.status.GetType()

to have a look at the type, and if a Custom Object, then

$_.status | Get-Member

to look at what's in it?

0 Kudos

Hi ted,

thanks for the reply, it is a customobject.

This get-member statement returns a list of NoteProperties with strange names:

     $_.status | Get-Member -MemberType NoteProperty

Returns:

     Name MemberType   Definition              

     ---- ----------   ----------              

     $    NoteProperty System.String $=Recurring

     @id  NoteProperty System.String @id=9

How should I proceed?

0 Kudos

Hi Ted,

I am 1 step closer. Executing:

     $_.status | Get-Member -MemberType NoteProperty | select definition

Gives me:

     System.String $=Completed

     System.String @id=1

But i only want "Completed"

I keep searching...

former_member197386
Active Contributor
0 Kudos

Hi Raoul,

Your question is now purely about PowerSchell programming, right?

(how to get the correct needed data from a structure?)

Regards,

Anthony

0 Kudos

Hi Anthony,

Yes I think it is, I am new to powershell.

I am looking into this RESTful SDK to see if it can replace our Java scheduling and monitoring tool we build around XI. So the RESTful SDK is also new.

Regards,

Raoul

ted_ueda
Employee
Employee
0 Kudos

Sorry for the delay - I had the answer but neglected to post

You likely already found the answer, but I do something like:

    write-host $schedules.schedules.schedule[1].status.'$'

that prints out the String value associated with the $ field (that needs to be single-quoted when referenced).

Hope that helps!

Regards,

Ted Ueda

0 Kudos

Hi Ted,

I also had some delay, Thanks for your answer, that was what I needed.

Regards,

Raoul

ted_ueda
Employee
Employee
0 Kudos

Thanks for the confirmation!

Ted

Answers (0)