VaunMcCarthy | 2022-08-21 02:26:21 UTC | #1
Hi guys
Here's a snippet of a script I've got working fine for datelastlogin:
(./gc.exe users get --expand="dateLastLogin" $($.id) | ConvertFrom-Json) | Select-Object id, name, dateLastLogin, state| ForEach-Object { Write-Host "$($.name),$($.dateLastLogin),$userLicense,$($.state)" }
I"m wanting to enhance that to expand on the lasttokenissued object and bring in the dateissued item from that but I can't get my head around how to do something like lasttokenissued.dateissued so that I have $($_.dateissued) available in my Write-Host line.
Any pointers?
plmcgrn | 2022-08-24 22:06:22 UTC | #2
EDIT: I raised a case with Genesys support. This API doesn't appear to be returning that data, and I hate when stuff doesn't work as documented.
Since it should be cast as a nested PSObject, it should be as simple as
(./gc.exe users get --expand="dateLastLogin,lastTokenIssued" $($_.id) | ConvertFrom-Json) | Select-Object id, name, dateLastLogin, state|
ForEach-Object {
Write-Host "$($_.name),$($_.dateLastLogin),$userLicense,$($_.state),$($_.lastTokenIssued.dateIssued)"
}
I'm using straight PowerShell scripting, not the PS EXE, but in my testing, I wasn't even getting the lastTokenIssued property back when calling the /api/v2/users API even with lastTokenIssued as an expand property. I think there's either a bug in the API, or bad documentation on requirements to get this property back when calling it.
VaunMcCarthy | 2022-08-24 22:32:47 UTC | #3
Thanks Paul, I'll be curious to see how Genesys respond to you.
plmcgrn | 2022-08-25 02:17:35 UTC | #4
Support got back to me. Apparently "lastTokenIssued" should be all lowercase, so "lasttokenissued". I'm declaring that a bug, rather than a documentation issue, because the return property IS in camel case as-documented.
Try this. PowerShell isn't case-sensitive with property names, thankfully.
(./gc.exe users get --expand="dateLastLogin,lasttokenissued" $($_.id) | ConvertFrom-Json) | Select-Object id, name, dateLastLogin, state|
ForEach-Object {
Write-Host "$($_.name),$($_.dateLastLogin),$userLicense,$($_.state),$($_.lastTokenIssued.dateIssued)"
}
Jerome.Saint-Marc | 2022-08-25 07:19:07 UTC | #5
Hello,
As a note, the "lasttokenissued" value (in lowercase), used in expand parameter, is documented in the Request Parameters (under API Request section) of the GET /api/v2/users endpoint.
Regards,
VaunMcCarthy | 2022-08-27 06:21:49 UTC | #6
Thanks Jerome - consistency would help old people like me :slight_smile:
This does work fine now as long as you consider the difference in case.
John_Carnell | 2022-09-06 17:36:59 UTC | #7
This post was migrated from the old Developer Forum.
ref: 15966