Microsoft declared that MDT will deprecated later this year 10/2025. https://learn.microsoft.com/en-us/mem/configmgr/core/plan-design/changes/deprecated/removed-and-deprecated-cmfeatures#deprecated-features
This made me look at how to make a custom prompts into SCCM task sequence to make sure the simple logics that have been intact with MDT will be again available after MDT integration will be removed from SCCM
So what this dude is on about once again..

Basically you can do much much more and this will be able to be done in a start of the task sequnce.


So this setting for example will set OSDComputername, SelectedOU and SelectedRole variable. These will then guide the task sequence with the logic provided afterwards.

This is the way to make dynamic variable to be placed into the domain join OU.
<#
Script version 0.1
Sets up with script the following SCCM variables that can then be used during the task sequece.
### OSDComputerName, SelectedOU, SelectedRole ###
OSDComputer does not need any follow ups. SelectedOU and SelectedRole will need guidance. Domain join can be done with LDAP://%SelectedOU%
Role can be used to guide the a folder section that installs the selected items accordingly or any way you want basically
Modifycations most likely will have to be made. Define the $ouList and $roleList selection according to the environment you are on.
#>
# Create the Task Sequence Environment
try {
$tsEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment
} catch {
Write-Error "This script must run inside an SCCM Task Sequence."
exit 1
}
Try
{
$TSProgressUI = new-object -comobject Microsoft.SMS.TSProgressUI
$TSProgressUI.CloseProgressDialog()
$TSProgressUI = $null
}
Catch
{
write-host "Could not find the TSProgressUI" -type Warning
Log-Error $_
}
# Load Windows Forms assembly
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
# Create the form
$form = New-Object System.Windows.Forms.Form
$form.Text = "Computer Configuration"
$form.Size = New-Object System.Drawing.Size(400, 300)
$form.StartPosition = "CenterScreen"
# Create a label for Computer Name
$labelComputerName = New-Object System.Windows.Forms.Label
$labelComputerName.Text = "Computer Name:"
$labelComputerName.Location = New-Object System.Drawing.Point(20, 20)
$labelComputerName.AutoSize = $true
$form.Controls.Add($labelComputerName)
# Create a textbox for Computer Name
$textboxComputerName = New-Object System.Windows.Forms.TextBox
$textboxComputerName.Location = New-Object System.Drawing.Point(150, 20)
$textboxComputerName.Size = New-Object System.Drawing.Size(200, 20)
$form.Controls.Add($textboxComputerName)
# Create a label for OU selection
$labelOU = New-Object System.Windows.Forms.Label
$labelOU.Text = "Select OU:"
$labelOU.Location = New-Object System.Drawing.Point(20, 60)
$labelOU.AutoSize = $true
$form.Controls.Add($labelOU)
# Create a dropdown (ComboBox) for OU
$dropdownOU = New-Object System.Windows.Forms.ComboBox
$dropdownOU.Location = New-Object System.Drawing.Point(150, 60)
$dropdownOU.Size = New-Object System.Drawing.Size(200, 20)
$dropdownOU.DropDownStyle = "DropDownList"
# Populate the dropdown with OUs - Get FQDN from AD
$ouList = @(
"OU=tietokoneet,DC=De,DC=Mo",
"OU=Computers,DC=De,DC=Mo",
"OU=Servers,DC=De,DC=Mo"
)
$dropdownOU.Items.AddRange($ouList)
$form.Controls.Add($dropdownOU)
# Create a label for Role selection
$labelRole = New-Object System.Windows.Forms.Label
$labelRole.Text = "Select Role:"
$labelRole.Location = New-Object System.Drawing.Point(20, 100)
$labelRole.AutoSize = $true
$form.Controls.Add($labelRole)
# Create a dropdown (ComboBox) for Role
$dropdownRole = New-Object System.Windows.Forms.ComboBox
$dropdownRole.Location = New-Object System.Drawing.Point(150, 100)
$dropdownRole.Size = New-Object System.Drawing.Size(200, 20)
$dropdownRole.DropDownStyle = "DropDownList"
# Populate the dropdown with roles
$roleList = @(
"Hallinto",
"Edu",
"Terveys"
)
$dropdownRole.Items.AddRange($roleList)
$form.Controls.Add($dropdownRole)
# Add an OK button
$okButton = New-Object System.Windows.Forms.Button
$okButton.Text = "OK"
$okButton.Location = New-Object System.Drawing.Point(100, 200)
$okButton.Add_Click({
if (-not $textboxComputerName.Text) {
[System.Windows.Forms.MessageBox]::Show("Please enter a Computer Name.")
return
}
if (-not $dropdownOU.SelectedItem) {
[System.Windows.Forms.MessageBox]::Show("Please select an OU.")
return
}
if (-not $dropdownRole.SelectedItem) {
[System.Windows.Forms.MessageBox]::Show("Please select a Role.")
return
}
# Write Task Sequence variables
$tsEnv.Value("OSDComputerName") = $textboxComputerName.Text
$tsEnv.Value("SelectedOU") = $dropdownOU.SelectedItem
$tsEnv.Value("SelectedRole") = $dropdownRole.SelectedItem
$form.Close()
})
$form.Controls.Add($okButton)
# Add a Cancel button
$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Text = "Cancel"
$cancelButton.Location = New-Object System.Drawing.Point(200, 200)
$cancelButton.Add_Click({
$form.Close()
})
$form.Controls.Add($cancelButton)
# Show the form
$form.Add_Shown({ $form.Activate() })
[void]$form.ShowDialog()
# Output result for logging
if ($tsEnv.Value("OSDComputerName") -and $tsEnv.Value("SelectedOU") -and $tsEnv.Value("SelectedRole")) {
Write-Output "Task Sequence Variables set:"
Write-Output "OSDComputerName: $($tsEnv.Value("OSDComputerName"))"
Write-Output "SelectedOU: $($tsEnv.Value("SelectedOU"))"
Write-Output "SelectedRole: $($tsEnv.Value("SelectedRole"))"
} else {
Write-Output "No variables were set."
}
Try
{
$TSProgressUI = new-object -comobject Microsoft.SMS.TSProgressUI
$TSProgressUI.ShowTSProgress($tsenv.Value("_SMSTSOrgName"), $tsenv.Value("_SMSTSPackageName"), $tsenv.Value("_SMSTSCustomProgressDialogMessage"), $tsenv.Value("_SMSTSCurrentActionName"), $tsenv.Value("_SMSTSNextInstructionPointer"), $tsenv.Value("_SMSTSInstructionTableSize"))
$TSProgressUI = $null
}
Catch
{
write-host "Could not find the TSProgressUI" -type warning
}
Leave a Reply