on 09-30-2015 3:43 PM
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.