So I'm able to connect to an API and generate items based on a template from that data. But what is stumping me is the ability to get a child JSON element of one that contains a colon.

For example the code below is what I have currently:

$parentPath = Get-Item -Path "master:\" -ID "{2EDC48D0-6134-48DB-B103-DE6F4103B8EE}"
$Faculty_TemplateID = "{E2524ACD-C438-4263-9088-3EFBACB8CD9E}"
$items = Invoke-RestMethod -uri "*API URL*"

foreach($f in $items){
  $faculty_firstName = $f.leadership_checkbox.first_name
  $faculty_lastName = $f.leadership_checkbox.last_name
  $faculty_position = $f.leadership_checkbox.title

  #creating of the item
  $faculty_item = New-Item -Parent $parentPath -Name $faculty_title -ItemType $Faculty_TemplateID

  #setting field values on the created items
    $faculty_item.Fields["Title"].Value = $faculty_title
    $faculty_item.Fields["First Name"].Value = $faculty_firstName
    $faculty_item.Fields["Last Name"].Value = $faculty_lastName

Where the code is setting the variables, I'd like to add another one

$faculty_firstName = $f.leadership_checkbox.first_name
$faculty_lastName = $f.leadership_checkbox.last_name
$faculty_position = $f.leadership_checkbox.title
$faculty_info = $f.leadership_checkbox.wp:someImportantInfo

Powershell throws an "Unexpected Token" error when I try to do this like normal. I've tried things like Join-Path but nothing I've found seems to be working. Any Ideas?

1 Answer 1


The colon is invalid PowerShell syntax.

For cases where the field name contains a space you can simply enclose it with quotes.

$item."Field Name"
$item.'Field Name"
  • Worked like a charm! Thank you!
    – Pinpaho
    Commented Nov 9, 2020 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.