Get-Contact
  • 1 Minute to read
  • Dark
    Light
  • PDF

Get-Contact

  • Dark
    Light
  • PDF

Article summary

Summary

Retrieves an existing contact.

Get-Contact
    -Id

Returns a contact object.

Parameters

ParameterTypeRequired?Notes
IdInt32YesThe contact id.

Examples

Get an existing contact

This example retrieves a specific contact and outputs it as JSON.

# Retrieve a specific contact by id
$data = Get-Contact -Id 12

Write-Output "Retrieved contact $($data.ContactId)"

# Convert the contact to output as JSON
$jsonOutput = $data | ConvertTo-Json -Depth 10

# For debug purposes, convert the data to output as JSON so we can see all the fields
Write-Output ""
Write-Output "JSON Results:"

$jsonOutput = $data | ConvertTo-Json -Depth 10

# Output the data
Write-Output $jsonOutput

Results of executing the script:

Retrieved contact 12

JSON Results:
{
  "ContactId": 12,
  "FirstName": "Adele",
  "LastName": "Butler",
  "FullName": "Adele Butler",
  "EmailAddress": "abutler@abdemo.com",
  "NameAndEmailAddress": "Adele Butler <abutler@abdemo.com>",
  "PhoneNumber": null,
  "TimeZoneIdentifier": "Central Standard Time",
  "EnableNotifications": false,
  "AllowPortalAccess": true,
  "IsFavorite": false,
  "NumberOfProjects": 78,
  "CreatedByFullName": "Service Account",
  "CreatedById": "410e109b-6ff5-4442-9670-cd5e3cd82a7f",
  "CreatedOn": "2016-10-02T16:22:37.2389772-05:00",
  "CreatedBy": null,
  "LastUpdatedByFullName": "Service Account",
  "LastUpdatedById": "410e109b-6ff5-4442-9670-cd5e3cd82a7f",
  "LastUpdatedOn": "2023-11-14T20:59:00.0052526+00:00",
  "LastUpdatedBy": null,
  "Fields": [
    {
      "FieldId": 50,
      "ObjectId": 7,
      "DataTypeId": 10,
      "DataTypeName": "Reference",
      "Label": "Skills",
      "IsRequired": false,
      "Position": 0,
      "Guid": 7413322756636,
      "IsSystemField": false,
      "IsReferenceValue": false,
      "DefaultValue": null,
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": {
        "ObjectFieldValueId": 421,
        "ObjectFieldId": 50,
        "ObjectId": 7,
        "PrimaryKeyId": 12,
        "ValueAsString": null,
        "ValueAsBoolean": null,
        "ValueAsNumber": null,
        "ValueAsDecimal": null,
        "ValueAsDate": null,
        "ReferenceObject": {
          "ObjectFieldReferenceObjectInstanceId": 1,
          "ObjectFieldValueId": 421,
          "ObjectId": 16,
          "Object": null,
          "PrimaryObjectId": 7,
          "PrimaryKeyId": 12,
          "KeyType": "Int32",
          "DisplayFormat": "%Name%",
          "IsSystemObject": false,
          "Name": null,
          "NumberOfValues": 2,
          "Values": [
            {
              "ObjectFieldReferenceObjectInstanceValueId": 1,
              "ObjectFieldReferenceObjectInstanceId": 1,
              "KeyAsString": null,
              "KeyAsInteger": 1,
              "KeyAsLong": null,
              "Value": "Test Skill I"
            },
            {
              "ObjectFieldReferenceObjectInstanceValueId": 2,
              "ObjectFieldReferenceObjectInstanceId": 1,
              "KeyAsString": null,
              "KeyAsInteger": 2,
              "KeyAsLong": null,
              "Value": "Test Skill II"
            }
          ]
        }
      },
      "ReferenceObject": null
    },
    {
      "FieldId": 67,
      "ObjectId": 7,
      "DataTypeId": 1,
      "DataTypeName": "Basic Text",
      "Label": "Office Location",
      "IsRequired": false,
      "Position": 1,
      "Guid": 1756477664260,
      "IsSystemField": false,
      "IsReferenceValue": false,
      "DefaultValue": null,
      "CopyPreviousValueOnSaveAndNew": false,
      "Value": {
        "ObjectFieldValueId": 1934,
        "ObjectFieldId": 67,
        "ObjectId": 7,
        "PrimaryKeyId": 12,
        "ValueAsString": "Minneapolis",
        "ValueAsBoolean": null,
        "ValueAsNumber": null,
        "ValueAsDecimal": null,
        "ValueAsDate": null,
        "ReferenceObject": null
      },
      "ReferenceObject": null
    }
  ]
}

What's Next