Paul Conway
New Member
- Messages
- 2
- Reaction score
- 0
- Points
- 1
I have a task variable set in the TSGUI at the beginning of the build process for the build technicians name
I can see this populates as expected

I am then trying to add this to the devices registry as part of the build for auditing purposes
the script I am trying to use is:
# Create an object to access the task sequence environment
$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
# Set variables to indicate value and key to set
$RegistryPath = "HKEY_LOCAL_MACHINE\SYSTEM"
$Name = "ImagingTechnician"
$Value = $tsenv.Value("_OSDTechnician")
# Create the key if it does not exist
If (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
# Now set the value
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType REG_SZ -Force
however this is failing, I ve tried using the variable as %OSDTechnician and OSDTechnician
the first of these also fails, the second added the value as OSDTechnician rather than the the value
How do I refer to the variable to get the correct value?
I can see this populates as expected

I am then trying to add this to the devices registry as part of the build for auditing purposes
the script I am trying to use is:
# Create an object to access the task sequence environment
$tsenv = New-Object -ComObject Microsoft.SMS.TSEnvironment
# Set variables to indicate value and key to set
$RegistryPath = "HKEY_LOCAL_MACHINE\SYSTEM"
$Name = "ImagingTechnician"
$Value = $tsenv.Value("_OSDTechnician")
# Create the key if it does not exist
If (-NOT (Test-Path $RegistryPath)) {
New-Item -Path $RegistryPath -Force | Out-Null
}
# Now set the value
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType REG_SZ -Force
however this is failing, I ve tried using the variable as %OSDTechnician and OSDTechnician
the first of these also fails, the second added the value as OSDTechnician rather than the the value
How do I refer to the variable to get the correct value?