Having made substantial progress accessing objects returned by an Invoke-RestMethod and is it possible to dig out items that are nested within a single response?
contactId : 598 isPrimaryContact : True salutation : firstName : KAREN lastName : MCPHERSON postAddressIds : @{DEF=513; DEL=513; BIL=513} communication : @{emails=; telephones=; messagingVoips=; websites=} contactStatus : @{current=} relationshipToAccount : @{isSupplier=False; isStaff=False} marketingDetails : @{isReceiveEmailNewsletter=True} financialDetails : @{priceListId=2; nominalCode=0; creditLimit=0; creditTermDays=0; currencyId=1; discountPercentage=0.00} assignment : @{current=} organisation : @{organisationId=598; name=ROSENTHAL MONTESSORI ELEMENTARY} createdByid : 0 createdOn : 2014-03-17T10:02:54.000-04:00 updatedOn : 2014-03-17T10:02:55.000-04:00 contactTags : 8
What I’m trying to do is to create a simple name and address file assembled from one or more JSON responses.
With the above, I can pipe to:
Select-Object contactId, firstName, lastname | ConvertTo.CSV
and end up with a nicely formatted csv file…
"598","McPherson", "Karen" "322","Schmoe", "Joe" etc. etc.
I’d like to include the Organization.Name (which is embedded in the hash table in the organization object.
Question 1. Can I dig out the name, so that it appears in my list?
"598","ROSENTHAL MONTESSORI ELEMENTARY", "McPherson", "Karen" "322","Springfield High School", Schmoe", "Joe"
I tried
Select-Object organization.name, contactId, firstName, lastname and Select-Object organization.[1] contactId, firstName, lastname
but these don’t return anything in the organization field.
Question 2,
There is also an address ID contained within the record as a hash table:
postAddressIds : @{DEF=513; DEL=513; BIL=513}
and I want to use the DELivery address ID…which I think need to use to make another JSON request for the address.
Somehow this all needs to get in a loop…
In SQL this would look like:
SELECT contactid, organization, firstName,lastName, address1, address2, city,state zip
FROM contacts, address
WHERE address.contactsid = contacts.contactid
Thanks so much for any ideas.