I found this while searching and was able to tweak it for my needs. Its works so I figured I would share in case anyone finds this while searching...LOL
This is a Powershell script that gets run right after the Install Operating System TS:
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
#Get Name and OS Disk from MDT
$MDTComputerName = $TSEnv.Value("OSDComputerName")
$MDTOSDisk = $TSEnv.Value("OSDisk")
# Read the current config
$config = Get-Content .\AutoPilotConfigurationFile.json | ConvertFrom-Json
# Add the computer name
$config | Add-Member "CloudAssignedDeviceName" $MDTComputerName
# Write the updated file
$targetDrive = $tsenv.Value("OSDisk")
$null = MkDir "$targetDrive\Windows\Provisioning\Autopilot" -Force
$destConfig = "$targetDrive\Windows\Provisioning\Autopilot\AutoPilotConfigurationFile.json"
$config | ConvertTo-JSON | Set-Content -Path $destConfig -Force
It will get the PCname set in MDT and insert it into the JSON file I exported for Autopilot. Seems to work very well so far.
Thanks,
Scott