Ajout du support de unattend

Ajout du script cmd à utiliser pour lancer DeployCenter
This commit is contained in:
benoit committed 2026-10-17 20:41:41 +02:00
1 parent 2019c565f5
commit e067721763
12 files changed
+663 -166

No files matched your search

+148 -23
View File
@@ -134,9 +134,26 @@ function New-DeployCenterDeploymentControls {
$profileSelector = New-DeployCenterPartitionProfileSelector -Parent $Parent -ProfileNames $ProfileNames -Theme $Theme -Font $Font
$profileSelector.ComboBox.Enabled = $false
$unattendLabel = New-Object System.Windows.Forms.Label
$unattendLabel.Name = 'lblUnattendProfile'
$unattendLabel.Text = 'Configuration de première ouverture'
$unattendLabel.Location = New-Object System.Drawing.Point(12, 190)
$unattendLabel.Size = New-Object System.Drawing.Size(320, 18)
$unattendLabel.Font = $Font
$unattendLabel.ForeColor = $Theme.Text
$unattendLabel.BackColor = [System.Drawing.Color]::Transparent
$unattendCombo = New-DeployCenterComboBox -Name 'cmbUnattendProfile' -Theme $Theme -Font $Font `
-Items @('Avec OOBE')
$unattendCombo.Location = New-Object System.Drawing.Point(12, 207)
$unattendCombo.Size = New-Object System.Drawing.Size([Math]::Max(250, $Parent.ClientSize.Width - 24), 26)
$unattendCombo.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left -bor [System.Windows.Forms.AnchorStyles]::Right
$unattendCombo.SelectedIndex = 0
$hostLabel = New-Object System.Windows.Forms.Label
$hostLabel.Name = 'lblHostName'
$hostLabel.Text = "Nom d’hôte"
$hostLabel.Location = New-Object System.Drawing.Point(12, 190)
$hostLabel.Location = New-Object System.Drawing.Point(12, 240)
$hostLabel.Size = New-Object System.Drawing.Size(220, 24)
$hostLabel.Font = $Font
$hostLabel.ForeColor = $Theme.Text
@@ -144,7 +161,7 @@ function New-DeployCenterDeploymentControls {
$hostTextBox = New-Object System.Windows.Forms.TextBox
$hostTextBox.Name = 'txtHostName'
$hostTextBox.Location = New-Object System.Drawing.Point([Math]::Max(244, $Parent.ClientSize.Width - 202), 187)
$hostTextBox.Location = New-Object System.Drawing.Point([Math]::Max(244, $Parent.ClientSize.Width - 202), 237)
$hostTextBox.Size = New-Object System.Drawing.Size(190, 26)
$hostTextBox.MaxLength = 15
$hostTextBox.Anchor = [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Right
@@ -152,17 +169,57 @@ function New-DeployCenterDeploymentControls {
$hostTextBox.ForeColor = $Theme.Text
$hostTextBox.Font = $Font
$Parent.Controls.AddRange(@($diskLabel, $diskCombo, $systemLabel, $chooseSystemButton, $selectedSystemLabel, $hostLabel, $hostTextBox))
$hostLabel.Visible = $false
$hostTextBox.Visible = $false
$Parent.Controls.AddRange(@($diskLabel, $diskCombo, $systemLabel, $chooseSystemButton, $selectedSystemLabel, $unattendLabel, $unattendCombo, $hostLabel, $hostTextBox))
return [pscustomobject]@{
DiskComboBox = $diskCombo
ChooseSystemButton = $chooseSystemButton
SelectedSystemLabel = $selectedSystemLabel
PartitionProfileLabel = $profileSelector.Label
PartitionProfileComboBox = $profileSelector.ComboBox
UnattendProfileLabel = $unattendLabel
UnattendProfileComboBox = $unattendCombo
HostNameLabel = $hostLabel
HostNameTextBox = $hostTextBox
}
}
function Set-DeployCenterUnattendHostNameVisibility {
param([Parameter(Mandatory=$true)]$Controls, [Parameter(Mandatory=$true)][bool]$ShowHostName)
$Controls.HostNameLabel.Visible = $ShowHostName
$Controls.HostNameTextBox.Visible = $ShowHostName
}
function Set-DeployCenterUnattendProfileChoices {
param(
[Parameter(Mandatory=$true)][System.Windows.Forms.ComboBox]$ComboBox,
[Parameter(Mandatory=$true)][AllowEmptyCollection()][object[]]$Profiles,
[AllowNull()][string]$EditionName,
[Parameter(Mandatory=$true)][string]$OobeChoice
)
$isServerEdition = -not [string]::IsNullOrWhiteSpace($EditionName) -and
$EditionName.IndexOf('server', [StringComparison]::OrdinalIgnoreCase) -ge 0
$target = if ($isServerEdition) { 'Server' } else { 'Workstation' }
$choices = @($OobeChoice)
if (-not [string]::IsNullOrWhiteSpace($EditionName)) {
$choices += @($Profiles | Where-Object { [string]$_.Target -eq $target } | ForEach-Object { [string]$_.Name })
}
$previousChoice = [string]$ComboBox.SelectedItem
$ComboBox.BeginUpdate()
try {
$ComboBox.Items.Clear()
foreach ($choice in $choices) { [void]$ComboBox.Items.Add($choice) }
$selectionIndex = $ComboBox.Items.IndexOf($previousChoice)
if ($selectionIndex -lt 0) { $selectionIndex = 0 }
$ComboBox.SelectedIndex = $selectionIndex
} finally {
$ComboBox.EndUpdate()
}
}
function Set-DeployCenterDeploymentControlsLayout {
param(
[Parameter(Mandatory=$true)][System.Windows.Forms.GroupBox]$Parent,
@@ -173,7 +230,8 @@ function Set-DeployCenterDeploymentControlsLayout {
$Controls.ChooseSystemButton.Location = New-Object System.Drawing.Point([Math]::Max(12, $Parent.ClientSize.Width - 144), 67)
$Controls.SelectedSystemLabel.Size = New-Object System.Drawing.Size($width, 22)
Set-DeployCenterPartitionProfileSelectorLayout -Label $Controls.PartitionProfileLabel -ComboBox $Controls.PartitionProfileComboBox -Width $width
$Controls.HostNameTextBox.Location = New-Object System.Drawing.Point([Math]::Max(244, $Parent.ClientSize.Width - 202), 187)
$Controls.UnattendProfileComboBox.Size = New-Object System.Drawing.Size($width, 26)
$Controls.HostNameTextBox.Location = New-Object System.Drawing.Point([Math]::Max(244, $Parent.ClientSize.Width - 202), 237)
$Controls.HostNameTextBox.Size = New-Object System.Drawing.Size(190, 26)
}
@@ -453,6 +511,89 @@ function Show-DeployCenterMessage {
$messageForm.Dispose()
}
function Show-DeployCenterDeploymentComplete {
param(
[Parameter(Mandatory=$true)][string]$Message,
[Parameter(Mandatory=$true)][System.Windows.Forms.Form]$Owner,
[Parameter(Mandatory=$true)][System.Collections.IDictionary]$Theme,
[Parameter(Mandatory=$true)][System.Drawing.Font]$Font
)
$dialog = New-Object System.Windows.Forms.Form
$dialog.Text = 'Déploiement terminé'
$dialog.StartPosition = 'CenterParent'
$dialog.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$dialog.ShowInTaskbar = $false
$dialog.MinimizeBox = $false
$dialog.MaximizeBox = $false
$dialog.BackColor = $Theme.Background
$dialog.ForeColor = $Theme.Text
$dialog.Font = $Font
$messageWidth = 390
$textSize = [System.Windows.Forms.TextRenderer]::MeasureText(
$Message, $Font, (New-Object System.Drawing.Size($messageWidth, 0)),
[System.Windows.Forms.TextFormatFlags]::WordBreak
)
$messageHeight = [Math]::Max(42, $textSize.Height + 8)
$dialog.ClientSize = New-Object System.Drawing.Size(470, ($messageHeight + 126))
$iconLabel = New-Object System.Windows.Forms.Label
$iconLabel.Location = New-Object System.Drawing.Point(18, 24)
$iconLabel.Size = New-Object System.Drawing.Size(34, 34)
$iconLabel.Text = 'i'
$iconLabel.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter
$iconLabel.Font = New-Object System.Drawing.Font('Segoe UI', [single]16, [System.Drawing.FontStyle]::Bold)
$iconLabel.ForeColor = $Theme.Accent
$iconLabel.BackColor = [System.Drawing.Color]::Transparent
$dialog.Controls.Add($iconLabel)
$messageLabel = New-Object System.Windows.Forms.Label
$messageLabel.Location = New-Object System.Drawing.Point(64, 20)
$messageLabel.Size = New-Object System.Drawing.Size($messageWidth, $messageHeight)
$messageLabel.Text = $Message
$messageLabel.ForeColor = $Theme.Text
$messageLabel.BackColor = [System.Drawing.Color]::Transparent
$messageLabel.TextAlign = [System.Drawing.ContentAlignment]::MiddleLeft
$messageLabel.Font = $Font
$dialog.Controls.Add($messageLabel)
$restartCheckBox = New-Object System.Windows.Forms.CheckBox
$restartCheckBox.Text = 'Redémarrer cet ordinateur après fermeture'
$restartCheckBox.Location = New-Object System.Drawing.Point(64, ($messageHeight + 34))
$restartCheckBox.Size = New-Object System.Drawing.Size(380, 26)
$restartCheckBox.Checked = $true
$restartCheckBox.ForeColor = $Theme.Text
$restartCheckBox.BackColor = [System.Drawing.Color]::Transparent
$restartCheckBox.Font = $Font
$dialog.Controls.Add($restartCheckBox)
$buttonPanel = New-Object System.Windows.Forms.Panel
$buttonPanel.Dock = [System.Windows.Forms.DockStyle]::Bottom
$buttonPanel.Height = 58
$buttonPanel.BackColor = $Theme.PanelAlt
$dialog.Controls.Add($buttonPanel)
$okButton = New-Object System.Windows.Forms.Button
$okButton.Text = 'OK'
$okButton.Location = New-Object System.Drawing.Point(362, 10)
$okButton.Size = New-Object System.Drawing.Size(92, 36)
$okButton.Font = $Font
$okButton.Cursor = [System.Windows.Forms.Cursors]::Hand
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
Set-DeployCenterButtonStyle -Button $okButton -Theme $Theme -Role 'PrimaryButton'
$buttonPanel.Controls.Add($okButton)
$dialog.AcceptButton = $okButton
$dialog.CancelButton = $okButton
try {
$result = $dialog.ShowDialog($Owner)
return ($result -eq [System.Windows.Forms.DialogResult]::OK -and $restartCheckBox.Checked)
} finally {
$dialog.Dispose()
}
}
function Show-DeployCenterConfirmation {
param(
[Parameter(Mandatory=$true)][string]$Title,
@@ -769,13 +910,6 @@ function Set-DeployCenterTheme {
$script:lblTitle.ForeColor = $script:Theme.Text
$script:lblSubtitle.ForeColor = $script:Theme.Secondary
if ($script:lblWinPE.Text -like "*WinPE*") {
$script:lblWinPE.ForeColor = $script:Theme.Success
}
else {
$script:lblWinPE.ForeColor = $script:Theme.Secondary
}
Set-DeployCenterButtonStyle -Button $script:btnChooseWindows -Theme $script:Theme -Role 'Button'
Set-DeployCenterButtonStyle -Button $script:btnLog -Theme $script:Theme -Role 'Button'
Set-DeployCenterButtonStyle -Button $script:btnRefresh -Theme $script:Theme -Role 'PrimaryButton'
@@ -1388,15 +1522,6 @@ function Update-HardwareView {
$script:lblFirmware.Text = "Firmware : $($info.Firmware)"
$script:lblArchitecture.Text = "Architecture : $($info.Architecture)"
if ($info.WinPE) {
$script:lblWinPE.Text = "Environnement : WinPE"
$script:lblWinPE.ForeColor = $script:Theme.Success
}
else {
$script:lblWinPE.Text = "Environnement : Windows classique"
$script:lblWinPE.ForeColor = $script:Theme.Secondary
}
$script:HardwareInventory = $info
$previousDiskIndex = $null
if ($null -ne $script:cmbDisk.SelectedItem -and $null -ne $script:cmbDisk.SelectedItem.Tag) {
@@ -1496,9 +1621,9 @@ function Update-DeployCenterLayout {
# Les deux panneaux superieurs conservent leur hauteur, mais s'etirent en largeur.
$script:groupPC.Location = New-Object System.Drawing.Point($m, 100)
$script:groupPC.Size = New-Object System.Drawing.Size($contentWidth, 105)
$script:groupDisks.Location = New-Object System.Drawing.Point($m, 220)
$script:groupDisks.Size = New-Object System.Drawing.Size($contentWidth, 226)
$script:groupPC.Size = New-Object System.Drawing.Size($contentWidth, 90)
$script:groupDisks.Location = New-Object System.Drawing.Point($m, 205)
$script:groupDisks.Size = New-Object System.Drawing.Size($contentWidth, 270)
Set-DiskSelectorWidth
$footerHeight = 26