I have a script that runs at end of sequence that I want to read the current computer name on what the TS is deploying to and then assign this name to a variable. I have tried the following:
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$TSEnv.value("OSDComputerName") = $ComputerName
But the script doesn't seem to work. Now I can successfully run it once computer is built and manually enter the computer name. I thought OSDComputerName is what SCCM uses to hold the current computer name on what the TS is running? The computer has a name and defined in Device Collection.
Anyone know what I am doing wrong?