Group Description
Microsoft Endpoint Manager is an integrated solution for managing all of your devices. Microsoft brings together Configuration Manager and Intune, without a complex migration, and with simplified licensing. Continue to leverage your existing Configuration Manager investments, while taking advantage of the power of the Microsoft cloud at your own pace.
The following Microsoft management solutions are all now part of the Microsoft Endpoint Manager brand:
Configuration Manager
Intune
Desktop Analytics
Autopilot
Other features in the Device Management Admin Console
Reply To: Task sequence UI import from ini file
-
Thanks Varun. For SCCM users we always recommend our Free SCCM task sequence orchestrator which has 18 extension attributes that can be assigned entries that originally go into the INI file. But since you use MDT, the process from the start to finish has to be done using PowerShell, leveraging the power of ‘Windows Forms’ or ‘Windows Presentation Foundation’.
Step 1: Create a Form with all the required fields. See a very short example below.
Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Application]::EnableVisualStyles() $storeInfo = New-Object system.Windows.Forms.Form $storeInfo.ClientSize = New-Object System.Drawing.Point(594,113) $storeInfo.text = "Store Information Window" $storeInfo.TopMost = $false $storeInfo.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#ffffff") $storeAddress = New-Object system.Windows.Forms.Label $storeAddress.text = "Store Address : " $storeAddress.AutoSize = $false $storeAddress.width = 91 $storeAddress.height = 6 $storeAddress.location = New-Object System.Drawing.Point(10,68) $storeAddress.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10) $IPAddress = New-Object system.Windows.Forms.Label $IPAddress.text = "IP Address : " $IPAddress.AutoSize = $false $IPAddress.width = 108 $IPAddress.height = 5 $IPAddress.location = New-Object System.Drawing.Point(10,20) $IPAddress.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10) $TextBox1 = New-Object system.Windows.Forms.TextBox $TextBox1.multiline = $false $TextBox1.width = 430 $TextBox1.height = 20 $TextBox1.location = New-Object System.Drawing.Point(145,15) $TextBox1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10) $TextBox2 = New-Object system.Windows.Forms.TextBox $TextBox2.multiline = $false $TextBox2.width = 430 $TextBox2.height = 20 $TextBox2.location = New-Object System.Drawing.Point(145,61) $TextBox2.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10) $storeInfo.controls.AddRange(@($storeAddress,$IPAddress,$TextBox1,$TextBox2))
Add extra fields like text boxes and combo boxes to suite your needs. This article can guide you in the right direction.
Step 2: Read your INI files and pre-populate necessary fields.
function Get-IniContent ($filePath) { $ini = @{} switch -regex -file $FilePath { "^\[(.+)\]" # Section { $section = $matches[1] $ini[$section] = @{} $CommentCount = 0 } "^(;.*)$" # Comment { $value = $matches[1] $CommentCount = $CommentCount + 1 $name = "Comment" + $CommentCount $ini[$section][$name] = $value } "(.+?)\s*=(.*)" # Key { $name,$value = $matches[1..2] $ini[$section][$name] = $value } } return $ini }
The above script was taken from Microsoft dev blog.
Step 3 : Read the values from the ‘PowerShell’ Form and write it to the INI file on your SYSTEM drive.
function Out-IniFile($InputObject, $FilePath) { $outFile = New-Item -ItemType file -Path $Filepath foreach ($i in $InputObject.keys) { if (!($($InputObject[$i].GetType().Name) -eq "Hashtable")) { #No Sections Add-Content -Path $outFile -Value "$i=$($InputObject[$i])" } else { #Sections Add-Content -Path $outFile -Value "[$i]" Foreach ($j in ($InputObject[$i].keys | Sort-Object)) { if ($j -match "^Comment[\d]+") { Add-Content -Path $outFile -Value "$($InputObject[$i][$j])" } else { Add-Content -Path $outFile -Value "$j=$($InputObject[$i][$j])" } } Add-Content -Path $outFile -Value "" } } }
The above script was taken from Microsoft dev blog.
If you run the PowerShell Form during the execution of the task sequence, remember to do the following.
$TSProgressUI = new-object -comobject Microsoft.SMS.TSProgressUI $TSProgressUI.CloseProgressDialog() $TSProgressUI = $null
The above commands turn off the progress UI.
Hope this helps.