$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number 'RITM0252601' -IncludeVariableSet
ForEach ($row in $Ritm.VariableSet) {
    $Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci' -Filter ("name=" + $row.host_name.split('.')[0])
    $NewApplicationSvc = Get-ITDServiceNowRecord -Table cmdb_ci_service_auto -SysId $row.application_info
    $CustomObj = $row | select licensing_restrictions,support_hours,dr_protection
    <#Update-ITDServiceNowRecord -Table 'cmdb_ci' -SysId $Ci.sys_id.value -Values @{
        u_nd_application_svc = $NewApplicationSvc.name.display_value
        short_description = ($CustomObj | ConvertTo-Json)
    }#>
}

# key values
Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter ('configuration_item=' + $Ci.sys_id.value)
New-ITDServiceNowRecord -Table 'cmdb_key_value' -Values @{
    configuration_item = $ci.sys_id.value
    key = 'AppName';
    value = $NewApplicationSvc.name.display_value
}







$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number 'RITM0252601' -IncludeVariableSet
ForEach ($row in $Ritm.VariableSet) {
    $Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci' -Filter ("name=itdzmtest666")
    $NewApplicationSvc = Get-ITDServiceNowRecord -Table cmdb_ci_service_auto -SysId $row.application_info
    $CustomObj = $row | select licensing_restrictions,support_hours,dr_protection
    Update-ITDServiceNowRecord -Table 'cmdb_ci' -SysId $Ci.sys_id.value -Values @{
        u_nd_application_svc = $NewApplicationSvc.name.display_value
        short_description = ($CustomObj | ConvertTo-Json)
    }
}

# key values
Get-ITDServiceNowRecord -Table 'cmdb_key_value' -Filter ('configuration_item=' + $Ci.sys_id.value)
New-ITDServiceNowRecord -Table 'cmdb_key_value' -Values @{
    configuration_item = $ci.sys_id.value
    key = 'AppName';
    value = $NewApplicationSvc.name.display_value
}

