#=========================================================================== # Begin Variables #=========================================================================== $Script:Lang = @{ FormA = "Install NanoServer with Powershell" FormA_Panel1_Label0 = "Programme d'Installation Nanoserver" FormA_Panel1_Label1 = "Bienvenue sur le logiciel d'installation des images Nano Server" FormA_Panel1_Label2 = "Continuer" FormA_Panel2_Label1 = "Sélectionnez le disque de destination" FormA_Panel2_ListView_Columns1 = "Nom" FormA_Panel2_ListView_Columns2 = "Taille Totale" FormA_Panel2_ListViewItem_SubItems1 = "Volume {0} : {1}" FormA_Panel2_ListViewItem_SubItems2 = "{0} Go" FormA_Panel2_Label2 = "Supprimer" FormA_Panel2_Label3 = "Continuer" FormA_Panel2_PictureBox_ToolTip = "Le disque sélectionné sera complètement formaté" Allocated = "Espace déjà alloué" NotAllocated = "Espace non alloué" FormA_Panel3_Label1 = "Choix des packages à ajouter" FormA_Panel3_Label2 = "Continuer" FormA_Panel3_Panel1_Label1 = "Type de destination" FormA_Panel3_Panel2_Label1 = "Type de licence" FormA_Panel3_Panel1_RadioButton1 = "Machine Virtuelle" FormA_Panel3_Panel1_RadioButton2 = "Machine Réelle" FormA_Panel3_Panel2_RadioButton1 = "Standard" FormA_Panel3_Panel2_RadioButton2 = "Datacenter" FormA_Panel4_Label0 = "Compléments d'informations" Optional = "Optionnel" Mandatory = "Obligatoire" FormA_Panel4_Label1 = "Nom de l'ordinateur" FormA_Panel4_Label2 = "Mot de passe administrateur" FormA_Panel4_Label3 = "Adresse IP" FormA_Panel4_Label4 = "Masque Réseau" FormA_Panel4_Label5 = "Serveur DNS" FormA_Panel4_Label6 = "Passerelle" FormA_Panel4_Label10 = "Installer" FormA_Panel5_Label0 = "Progression d'installation" FormA_Panel5_Label1 = "Préparation du disque" FormA_Panel5_Label2 = "Formatage du disque" FormA_Panel5_Label3 = "Préparation de la configuration" FormA_Panel5_Label4 = "Déploiement de la configuration" FormA_Panel5_Label5 = "Finalisation" } $Script:Packs = ( "Hyper-V role", "Compute", "Failover Clustering", "FailoverCluster", "EOM Drivers pour Host", "OEM-Drivers", "File Server role", "Storage", "Windows Defender", "Defender", "DNS Server role", "DNS", "Desired State Configuration (DSC)", "DSC", "Internet Information Server (IIS)", "IIS", "Host support for Windows Containers", "Containers", "SCVM Manager Premier agent", "SCVMM", "SCVM Manager Second agent", "SCVMM-Compute", "Network Performance Diagnostics Service", "NPDS", "Data Center Bridging", "DCB", "Ability to boot and run from a RAM disk", "BootFromWim", "Secure Startup", "SecureStartup", "Shielded VM", "ShieldedVM" ) #=========================================================================== # Begin Function I #=========================================================================== Function Check-EndString { [CmdletBinding()] [OutputType([String])] Param( [Parameter(Mandatory = $True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] [String]$Value ) If ($Value.Substring($Value.Length-1,1) -ne "\") { $Value+="\" } Return $Value } Function Get-BiosType { [CmdletBinding()] Param( [switch]$Name = $False ) Filter MyFilter1 { If ( ($_ -eq 1) -or ($_ -eq 2) ) { $_ } Else { 1 } } Filter MyFilter2 { If ( $_ -eq 2 ) { "GPT" } Else { "MBR" } } Return (Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control).PEFirmwareType | ForEach-Object { If ($Name) { ($_ | MyFilter2) } Else { ($_ | MyFilter1) } } } Function Get-Disk_List { [CmdletBinding()] Param() $Script:Disk_List = Get-Disk | Where-Object {($_.Size -ge 2GB)} | Sort-Object -Property Number $Script:Disk_List_Letters = (Get-WMIObject -Class Win32_Volume).DriveLetter | Where-Object { $_ -ne $null } | ForEach-Object { $_.Substring(0,1) } | Sort-Object $Script:Disk_List_Spare = [Char]'C'..[Char]'Z' | Where-Object { ($Disk_List_Letters -notcontains [Char]$_) } | ForEach-Object { [Char]$_ } } Function Set-ListView_SubItems { [CmdletBinding()] Param() $Disk_List | ForEach-Object { $FormA_Panel2_ListView.Items.Item($_.DiskNumber).SubItems.Item(1).Text = ($Lang.FormA_Panel2_ListViewItem_SubItems1 -f $_.DiskNumber,$(If ($_.PartitionStyle -eq "RAW") { $Lang.NotAllocated } Else { $Lang.Allocated }) ) $FormA_Panel2_ListView.Items.Item($_.DiskNumber).SubItems.Item(2).Text = $Lang.FormA_Panel2_ListViewItem_SubItems2 -f [Math]::Round($_.Size / 1GB, 2) } $FormA_Panel2_ListView.TopItem.Selected = $False $FormA_Panel2_ListView.TopItem.Selected = $True } Function ConvertTo-DottedDecimalIP { <# .Synopsis Returns a dotted decimal IP address from either an unsigned 32-bit integer or a dotted binary string. .Description ConvertTo-DottedDecimalIP uses a regular expression match on the input string to convert to an IP address. .Parameter IPAddress A string representation of an IP address from either UInt32 or dotted binary. #> [CmdLetBinding()] param( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] [String]$IPAddress ) process { Switch -RegEx ($IPAddress) { "([01]{8}.){3}[01]{8}" { return [String]::Join('.', $( $IPAddress.Split('.') | ForEach-Object { [Convert]::ToUInt32($_, 2) } )) } "\d" { $IPAddress = [UInt32]$IPAddress $DottedIP = $( For ($i = 3; $i -gt -1; $i--) { $Remainder = $IPAddress % [Math]::Pow(256, $i) ($IPAddress - $Remainder) / [Math]::Pow(256, $i) $IPAddress = $Remainder } ) return [String]::Join('.', $DottedIP) } default { Write-Error "Cannot convert this format" } } } } Function ConvertTo-Mask { <# .Synopsis Returns a dotted decimal subnet mask from a mask length. .Description ConvertTo-Mask returns a subnet mask in dotted decimal format from an integer value ranging between 0 and 32. ConvertTo-Mask first creates a binary string from the length, converts that to an unsigned 32-bit integer then calls ConvertTo-DottedDecimalIP to complete the operation. .Parameter MaskLength The number of bits which must be masked. #> [CmdLetBinding()] param( [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)] [Alias("Length")] [ValidateRange(0, 32)] $MaskLength ) Process { return ConvertTo-DottedDecimalIP ([Convert]::ToUInt32($(("1" * $MaskLength).PadRight(32, "0")), 2)) } } #=========================================================================== # Begin PowerShell Part I #=========================================================================== [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") If (-not ([System.Windows.Forms.Control]::IsKeyLocked('NumLock'))) { $Wsh = New-Object -ComObject WScript.Shell $Wsh.SendKeys('{NUMLOCK}') } Clear $Script:Path = "{0}\ISO\" -f ((Get-WMIObject -Class Win32_Volume).DriveLetter | Where-Object { $_ -ne $null } | Sort-Object | Where-Object { Test-Path -Path $("{0}\ISO" -f $_) -PathType Container }) $Script:Path_NanoServer = $Path + "NanoServer" Get-Variable -Name Path* | Where-Object { $_.VaLue = Check-EndString($_.VaLue) } $Script:Install = $False #=========================================================================== # Begin Form Objects I #=========================================================================== $Script:FormA = New-Object System.Windows.Forms.Form $Script:FormA_Panel1 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel1_Label0 = New-Object System.Windows.Forms.Label $Script:FormA_Panel1_Label0_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel1_Label0_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel1_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel1_Label1_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel1_Label1_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel1_Label2 = New-Object System.Windows.Forms.Label $Script:FormA_Panel1_Label2_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel1_Label2_Font = New-Object System.Drawing.Font("Times New Roman",22,[System.Drawing.FontStyle]::Italic) $formA.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($Path + "nano.ico") $FormA.Size = New-Object System.Drawing.Size(0,0) $FormA.BackColor = "DarkBlue" $FormA.FormBorderStyle = "FixedDialog" $FormA.KeyPreview = $True $FormA.MaximizeBox = $False $FormA.MinimizeBox = $False $FormA.ShowInTaskbar = $False $FormA.SizeGripStyle = "Hide" $FormA.StartPosition = "CenterScreen" $FormA.Text = $Lang.FormA $FormA.Topmost = $True $FormA.AutoSize = $True $FormA_Panel1.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel1.Size = New-Object System.Drawing.Size(700,450) $FormA_Panel1.BackColor = "Transparent" $FormA.Controls.Add($FormA_Panel1) $FormA_Panel1_Label0_Padding.All = 0 $FormA_Panel1_Label0_Padding.Left = 25 $FormA_Panel1_Label0.Font = $FormA_Panel1_Label0_Font $FormA_Panel1_Label0.AutoSize = $True $FormA_Panel1_Label0.BackColor = "Transparent" $FormA_Panel1_Label0.BackgroundImage = [System.Drawing.Image]::Fromfile($Path + "Logo.png") $FormA_Panel1_Label0.BackgroundImageLayout = "None" $FormA_Panel1_Label0.ForeColor = "Window" $FormA_Panel1_Label0.Padding = $FormA_Panel1_Label0_Padding $FormA_Panel1_Label0.Text = $Lang.FormA_Panel1_Label0 $FormA_Panel1_Label0.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel1.Controls.Add($FormA_Panel1_Label0) $FormA_Panel1_Label0.Location = New-Object System.Drawing.Point((($FormA_Panel1.Width - $FormA_Panel1_Label0.Width)/2),50) $FormA_Panel1_Label1_Padding.All = 0 $FormA_Panel1_Label1.Font = $FormA_Panel1_Label1_Font $FormA_Panel1_Label1.AutoSize = $True $FormA_Panel1_Label1.BackColor = "Transparent" $FormA_Panel1_Label1.ForeColor = "Window" $FormA_Panel1_Label1.Padding = $FormA_Panel1_Label1_Padding $FormA_Panel1_Label1.Text = $Lang.FormA_Panel1_Label1 $FormA_Panel1_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel1.Controls.Add($FormA_Panel1_Label1) $FormA_Panel1_Label1.Location = New-Object System.Drawing.Point((($FormA_Panel1.Width - $FormA_Panel1_Label1.Width)/2),140) $FormA_Panel1_Label2_Padding.Left = 50 $FormA_Panel1_Label2_Padding.Right = 50 $FormA_Panel1_Label2_Padding.Bottom = 5 $FormA_Panel1_Label2_Padding.Top = 5 $FormA_Panel1_Label2.Font = $FormA_Panel1_Label2_Font $FormA_Panel1_Label2.AutoSize = $True $FormA_Panel1_Label2.BackColor = "Transparent" $FormA_Panel1_Label2.ForeColor = "Window" $FormA_Panel1_Label2.Padding = $FormA_Panel1_Label2_Padding $FormA_Panel1_Label2.Text = $Lang.FormA_Panel1_Label2 $FormA_Panel1_Label2.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel1_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel1.Controls.Add($FormA_Panel1_Label2) $FormA_Panel1_Label2.Location = New-Object System.Drawing.Point((($FormA_Panel1.Width - $FormA_Panel1_Label2.Width)/2),260) #=========================================================================== # Begin Form Event I #=========================================================================== $FormA_Panel1_Label2.Add_Click({ $Script:Install = $True $FormA.Close() }) $FormA_Panel1_Label2.Add_MouseHover({ $FormA_Panel1_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $FormA.Cursor = [System.Windows.Forms.Cursors]::Hand }) $FormA_Panel1_Label2.Add_MouseLeave({ $FormA_Panel1_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA.Cursor = [System.Windows.Forms.Cursors]::Default }) $FormA.Add_Shown({ $FormA.Activate() }) #=========================================================================== # Begin PowerShell Part II #=========================================================================== [void] $FormA.ShowDialog() If (-not $Install) { Exit } $Script:Bios_Type = Get-BiosType $Script:Bios_Type_Name = Get-BiosType -Name Get-Disk_List $Install = $False $FormA.Controls.Remove($FormA_Panel1) Remove-Variable -Name FormA_Panel1* -Force -ErrorAction SilentlyContinue -Confirm:$False #=========================================================================== # Begin Form Objects II #=========================================================================== $Script:FormA_Panel2 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel2_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel2_Label1_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel2_Label1_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel2_ListView = New-Object System.Windows.Forms.ListView $Script:FormA_Panel2_ListView_Font = New-Object System.Drawing.Font("Times New Roman",12,[System.Drawing.FontStyle]::Bold) $Script:FormA_Panel2_ImageList = new-Object System.Windows.Forms.ImageList $Script:FormA_Panel2_ListViewItem_Font = New-Object System.Drawing.Font("Arial",12,[System.Drawing.FontStyle]::Regular) $Script:FormA_Panel2_Label2 = New-Object System.Windows.Forms.Label $Script:FormA_Panel2_Label2_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel2_Label2_Font = New-Object System.Drawing.Font("Times New Roman",22,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel2_Label3 = New-Object System.Windows.Forms.Label $Script:FormA_Panel2_Label3_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel2_Label3_Font = New-Object System.Drawing.Font("Times New Roman",22,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel2_PictureBox = New-Object Windows.Forms.PictureBox $Script:FormA_Panel2_PictureBox_ToolTip = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel2_PictureBox_Image = [System.Drawing.Image]::FromFile($Path + "Help.png") $FormA_Panel2.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel2.Size = New-Object System.Drawing.Size(700,450) $FormA_Panel2.BackColor = "Transparent" $FormA.Controls.Add($FormA_Panel2) $FormA_Panel2_Label1_Padding.All = 0 $FormA_Panel2_Label1.Font = $FormA_Panel2_Label1_Font $FormA_Panel2_Label1.AutoSize = $True $FormA_Panel2_Label1.BackColor = "Transparent" $FormA_Panel2_Label1.ForeColor = "Window" $FormA_Panel2_Label1.Padding = $FormA_Panel2_Label1_Padding $FormA_Panel2_Label1.Text = $Lang.FormA_Panel2_Label1 $FormA_Panel2_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel2.Controls.Add($FormA_Panel2_Label1) $FormA_Panel2_Label1.Location = New-Object System.Drawing.Point((($FormA_Panel2.Width - $FormA_Panel2_Label1.Width)/2),40) $FormA_Panel2_ListView.View = 'Details' $FormA_Panel2_ListView.FullRowSelect = $True $FormA_Panel2_ListView.AllowColumnReorder = $False $FormA_Panel2_ListView.Scrollable = $True $FormA_Panel2_ListView.GridLines = $False $FormA_Panel2_ListView.MultiSelect = $False $FormA_Panel2_ListView.Location = New-Object System.Drawing.Point(40,90) $FormA_Panel2_ListView.Size = New-Object System.Drawing.Size($($FormA_Panel2.Width - $FormA_Panel2_ListView.Left * 2), $($FormA_Panel2.Height - $FormA_Panel2_ListView.Top - 120)) $FormA_Panel2_ImageList.Images.Add([Drawing.Image]::FromFile($Path + "hd.png")) $FormA_Panel2_ImageList.ImageSize = New-Object System.Drawing.Size(48,48) $FormA_Panel2_ListView.SmallImageList = $FormA_Panel2_ImageList $FormA_Panel2_ListView.Font = $FormA_Panel2_ListView_Font [Void] $FormA_Panel2_ListView.Columns.Add('', -2) [Void] $FormA_Panel2_ListView.Columns.Add($Lang.FormA_Panel2_ListView_Columns1, 380, [System.Windows.Forms.HorizontalAlignment]::Left) [Void] $FormA_Panel2_ListView.Columns.Add($Lang.FormA_Panel2_ListView_Columns2, 160, [System.Windows.Forms.HorizontalAlignment]::Left) $Disk_List | ForEach-Object { [Void] $FormA_Panel2_ListView.Items.Add($_.DiskNumber,'', 0) $FormA_Panel2_ListView.Items.Item($_.DiskNumber).Tag = $_.DiskNumber $FormA_Panel2_ListView.Items.Item($_.DiskNumber).Font = $FormA_Panel2_ListViewItem_Font [Void] $FormA_Panel2_ListView.Items.Item($_.DiskNumber).SubItems.Add('') [Void] $FormA_Panel2_ListView.Items.Item($_.DiskNumber).SubItems.Add('') } Set-ListView_SubItems $FormA_Panel2.Controls.Add($FormA_Panel2_ListView) $FormA_Panel2_Label2_Padding.Left = 50 $FormA_Panel2_Label2_Padding.Right = 50 $FormA_Panel2_Label2_Padding.Bottom = 5 $FormA_Panel2_Label2_Padding.Top = 5 $FormA_Panel2_Label2.Font = $FormA_Panel2_Label2_Font $FormA_Panel2_Label2.AutoSize = $True $FormA_Panel2_Label2.BackColor = "Transparent" $FormA_Panel2_Label2.ForeColor = "Window" $FormA_Panel2_Label2.Padding = $FormA_Panel2_Label2_Padding $FormA_Panel2_Label2.Text = $Lang.FormA_Panel2_Label2 $FormA_Panel2_Label2.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel2.Controls.Add($FormA_Panel2_Label2) $FormA_Panel2_Label2.Location = New-Object System.Drawing.Point(50,360) $FormA_Panel2_Label3_Padding.Left = 50 $FormA_Panel2_Label3_Padding.Right = 50 $FormA_Panel2_Label3_Padding.Bottom = 5 $FormA_Panel2_Label3_Padding.Top = 5 $FormA_Panel2_Label3.Font = $FormA_Panel2_Label3_Font $FormA_Panel2_Label3.AutoSize = $True $FormA_Panel2_Label3.BackColor = "Transparent" $FormA_Panel2_Label3.ForeColor = "Window" $FormA_Panel2_Label3.Padding = $FormA_Panel2_Label3_Padding $FormA_Panel2_Label3.Text = $Lang.FormA_Panel2_Label3 $FormA_Panel2_Label3.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel2.Controls.Add($FormA_Panel2_Label3) $FormA_Panel2_Label3.Location = New-Object System.Drawing.Point(($FormA_Panel2.Width - $FormA_Panel2_Label3.Width - 50),360) $FormA_Panel2_PictureBox.Width = $FormA_Panel2_PictureBox_Image.Size.Width $FormA_Panel2_PictureBox.Height = $FormA_Panel2_PictureBox_Image.Size.Height $FormA_Panel2_PictureBox.Location = New-Object System.Drawing.Point(5,5) $FormA_Panel2_PictureBox.Image = $FormA_Panel2_PictureBox_Image $FormA_Panel2_PictureBox_ToolTip.settooltip($FormA_Panel2_PictureBox, $Lang.FormA_Panel2_PictureBox_ToolTip) $FormA_Panel2.controls.add($FormA_Panel2_PictureBox) #=========================================================================== # Begin Form Event II #=========================================================================== #$FormA_Panel2_ListView.Add_ColumnWidthChanged({ # If ($FormA_Panel2_ListView.Items.Count -lt 3) { # $FormA_Panel2_ListView.Columns.Item($_.ColumnIndex).Tag = $FormA_Panel2_ListView.Columns.Item($_.ColumnIndex).Width # } Else { # $FormA_Panel2_ListView.Columns.Item($_.ColumnIndex).Width = $FormA_Panel2_ListView.Columns.Item($_.ColumnIndex).Tag # } #}) $FormA_Panel2_Label2.Add_Click({ If ($FormA_Panel2_Label2.ForeColor -ne "Gray") { $FormA.Cursor = [System.Windows.Forms.Cursors]::WaitCursor Get-Disk -Number $FormA_Panel2_ListView.SelectedItems.Tag | Clear-Disk -RemoveData -RemoveOEM -Confirm:$False -ErrorAction SilentlyContinue Get-Disk_List Set-ListView_SubItems $FormA.Cursor = [System.Windows.Forms.Cursors]::Default } }) $FormA_Panel2_Label3.Add_Click({ If ($FormA_Panel2_Label3.ForeColor -ne "Gray") { $Script:Install = $True $Script:Disk_Number = $FormA_Panel2_ListView.SelectedItems.Tag $FormA.Close() } }) $FormA_Panel2_ListView.Add_SelectedIndexChanged({ If (($Disk_List | Where-Object DiskNumber -eq $FormA_Panel2_ListView.SelectedItems.Tag).PartitionStyle -eq "RAW") { #$FormA_Panel2_Label2.ForeColor = "Gray" $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::None $FormA_Panel2_Label3.ForeColor = "Window" $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D } ElseIf (-not $FormA_Panel2_ListView.SelectedItems.Tag) { #$FormA_Panel2_Label2.ForeColor = "Gray" $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::None #$FormA_Panel2_Label3.ForeColor = "Gray" $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::None } Else { $FormA_Panel2_Label2.ForeColor = "Window" $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel2_Label3.ForeColor = "Window" $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D } }) $FormA_Panel2_Label2.Add_MouseHover({ If ($FormA_Panel2_Label2.ForeColor -ne "Gray") { $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $FormA.Cursor = [System.Windows.Forms.Cursors]::Hand } }) $FormA_Panel2_Label2.Add_MouseLeave({ If ($FormA_Panel2_Label2.ForeColor -ne "Gray") { $FormA_Panel2_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA.Cursor = [System.Windows.Forms.Cursors]::Default } }) $FormA_Panel2_Label3.Add_MouseHover({ If ($FormA_Panel2_Label3.ForeColor -ne "Gray") { $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $FormA.Cursor = [System.Windows.Forms.Cursors]::Hand } }) $FormA_Panel2_Label3.Add_MouseLeave({ If ($FormA_Panel2_Label3.ForeColor -ne "Gray") { $FormA_Panel2_Label3.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA.Cursor = [System.Windows.Forms.Cursors]::Default } }) #=========================================================================== # Begin PowerShell Part III #=========================================================================== [void] $FormA.ShowDialog() If (-not $Install) { Exit } $Install = $False $FormA.Controls.Remove($FormA_Panel2) Remove-Variable -Name FormA_Panel2* -Force -ErrorAction SilentlyContinue -Confirm:$False #=========================================================================== # Begin Form Objects III #=========================================================================== $Script:FormA_Panel3 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel3_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel3_Label1_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel3_Label1_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel3_CheckedListBox = New-Object System.Windows.Forms.CheckedListBox $Script:FormA_Panel3_CheckedListBox_Font = New-Object System.Drawing.Font("Times New Roman",11,[System.Drawing.FontStyle]::Regular) $Script:FormA_Panel3_Label2 = New-Object System.Windows.Forms.Label $Script:FormA_Panel3_Label2_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel3_Label2_Font = New-Object System.Drawing.Font("Times New Roman",22,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel3_Panel1 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel3_Panel1_RadioButton1 = New-Object System.Windows.Forms.RadioButton $Script:FormA_Panel3_Panel1_RadioButton2 = New-Object System.Windows.Forms.RadioButton $Script:FormA_Panel3_Panel1_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel3_Panel1_Label1_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel3_Panel1_Label1_Font = New-Object System.Drawing.Font("Times New Roman",18,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel3_Panel2 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel3_Panel2_RadioButton1 = New-Object System.Windows.Forms.RadioButton $Script:FormA_Panel3_Panel2_RadioButton2 = New-Object System.Windows.Forms.RadioButton $Script:FormA_Panel3_Panel2_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel3_Panel2_Label1_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel3_Panel2_Label1_Font = New-Object System.Drawing.Font("Times New Roman",18,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel3_RadioButton_Font = New-Object System.Drawing.Font("Times New Roman",11,[System.Drawing.FontStyle]::Regular) $FormA_Panel3.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel3.Size = New-Object System.Drawing.Size(700,450) $FormA_Panel3.BackColor = "Transparent" $FormA.Controls.Add($FormA_Panel3) $FormA_Panel3_Label1_Padding.All = 0 $FormA_Panel3_Label1.Font = $FormA_Panel3_Label1_Font $FormA_Panel3_Label1.AutoSize = $True $FormA_Panel3_Label1.BackColor = "Transparent" $FormA_Panel3_Label1.ForeColor = "Window" $FormA_Panel3_Label1.Padding = $FormA_Panel3_Label1_Padding $FormA_Panel3_Label1.Text = $Lang.FormA_Panel3_Label1 $FormA_Panel3_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel3.Controls.Add($FormA_Panel3_Label1) $FormA_Panel3_Label1.Location = New-Object System.Drawing.Point(((380 - $FormA_Panel3_Label1.Width)/2),20) $FormA_Panel3_CheckedListBox.Location = New-Object System.Drawing.Size(20,60) $FormA_Panel3_CheckedListBox.Size = New-Object System.Drawing.Size(360,320) $FormA_Panel3_CheckedListBox.Font = $FormA_Panel3_CheckedListBox_Font For ($Key=0; $Key -lt $Packs.Count; $key +=2 ) { [Void] $FormA_Panel3_CheckedListBox.Items.Add($Packs[$Key], $False) } $FormA_Panel3.Controls.Add($FormA_Panel3_CheckedListBox) $FormA_Panel3_Panel1.Location = New-Object System.Drawing.Size(400,60) $FormA_Panel3_Panel1.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel1.BackColor = "Transparent" $FormA_Panel3_Panel1.AutoSize = $True $FormA_Panel3.Controls.Add($FormA_Panel3_Panel1) $FormA_Panel3_Panel1_Label1_Padding.All = 0 $FormA_Panel3_Panel1_Label1.Font = $FormA_Panel3_Panel1_Label1_Font $FormA_Panel3_Panel1_Label1.AutoSize = $True $FormA_Panel3_Panel1_Label1.BackColor = "Transparent" $FormA_Panel3_Panel1_Label1.ForeColor = "Window" $FormA_Panel3_Panel1_Label1.Padding = $FormA_Panel3_Panel1_Label1_Padding $FormA_Panel3_Panel1_Label1.Text = $Lang.FormA_Panel3_Panel1_Label1 $FormA_Panel3_Panel1_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel3_Panel1.Controls.Add($FormA_Panel3_Panel1_Label1) $FormA_Panel3_Panel1_Label1.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel3_Panel1_RadioButton1.Location = New-Object System.Drawing.Size(0,$FormA_Panel3_Panel1_Label1.Height) $FormA_Panel3_Panel1_RadioButton1.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel1_RadioButton1.AutoSize = $True $FormA_Panel3_Panel1_RadioButton1.Font = $FormA_Panel3_RadioButton_Font $FormA_Panel3_Panel1_RadioButton1.ForeColor = "Window" $FormA_Panel3_Panel1_RadioButton1.Text = $Lang.FormA_Panel3_Panel1_RadioButton1 $FormA_Panel3_Panel1_RadioButton1.Tag = "Guest" $FormA_Panel3_Panel1_RadioButton1.Checked = $True $FormA_Panel3_Panel1.Controls.Add($FormA_Panel3_Panel1_RadioButton1) $FormA_Panel3_Panel1_RadioButton2.Location = New-Object System.Drawing.Size(0,($FormA_Panel3_Panel1_Label1.Height + $FormA_Panel3_Panel1_RadioButton1.Height)) $FormA_Panel3_Panel1_RadioButton2.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel1_RadioButton2.AutoSize = $True $FormA_Panel3_Panel1_RadioButton2.Font = $FormA_Panel3_RadioButton_Font $FormA_Panel3_Panel1_RadioButton2.ForeColor = "Window" $FormA_Panel3_Panel1_RadioButton2.Text = $Lang.FormA_Panel3_Panel1_RadioButton2 $FormA_Panel3_Panel1_RadioButton2.Tag = "Host" $FormA_Panel3_Panel1.Controls.Add($FormA_Panel3_Panel1_RadioButton2) $FormA_Panel3_Panel2.Location = New-Object System.Drawing.Size(400,200) $FormA_Panel3_Panel2.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel2.BackColor = "Transparent" $FormA_Panel3_Panel2.AutoSize = $True $FormA_Panel3.Controls.Add($FormA_Panel3_Panel2) $FormA_Panel3_Panel2_Label1_Padding.All = 0 $FormA_Panel3_Panel2_Label1.Font = $FormA_Panel3_Panel2_Label1_Font $FormA_Panel3_Panel2_Label1.AutoSize = $True $FormA_Panel3_Panel2_Label1.BackColor = "Transparent" $FormA_Panel3_Panel2_Label1.ForeColor = "Window" $FormA_Panel3_Panel2_Label1.Padding = $FormA_Panel3_Panel2_Label1_Padding $FormA_Panel3_Panel2_Label1.Text = $Lang.FormA_Panel3_Panel2_Label1 $FormA_Panel3_Panel2_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel3_Panel2.Controls.Add($FormA_Panel3_Panel2_Label1) $FormA_Panel3_Panel2_Label1.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel3_Panel2_RadioButton1.Location = New-Object System.Drawing.Size(0,$FormA_Panel3_Panel2_Label1.Height) $FormA_Panel3_Panel2_RadioButton1.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel2_RadioButton1.AutoSize = $True $FormA_Panel3_Panel2_RadioButton1.Font = $FormA_Panel3_RadioButton_Font $FormA_Panel3_Panel2_RadioButton1.ForeColor = "Window" $FormA_Panel3_Panel2_RadioButton1.Text = $Lang.FormA_Panel3_Panel2_RadioButton1 $FormA_Panel3_Panel2_RadioButton1.Tag = "Standard" $FormA_Panel3_Panel2_RadioButton1.Checked = $True $FormA_Panel3_Panel2.Controls.Add($FormA_Panel3_Panel2_RadioButton1) $FormA_Panel3_Panel2_RadioButton2.Location = New-Object System.Drawing.Size(0,($FormA_Panel3_Panel2_Label1.Height + $FormA_Panel3_Panel2_RadioButton1.Height)) $FormA_Panel3_Panel2_RadioButton2.Size = New-Object System.Drawing.Size(0,0) $FormA_Panel3_Panel2_RadioButton2.AutoSize = $True $FormA_Panel3_Panel2_RadioButton2.Font = $FormA_Panel3_RadioButton_Font $FormA_Panel3_Panel2_RadioButton2.ForeColor = "Window" $FormA_Panel3_Panel2_RadioButton2.Text = $Lang.FormA_Panel3_Panel2_RadioButton2 $FormA_Panel3_Panel2_RadioButton2.Tag = "Datacenter" $FormA_Panel3_Panel2.Controls.Add($FormA_Panel3_Panel2_RadioButton2) $FormA_Panel3_Label2_Padding.Left = 50 $FormA_Panel3_Label2_Padding.Right = 50 $FormA_Panel3_Label2_Padding.Bottom = 5 $FormA_Panel3_Label2_Padding.Top = 5 $FormA_Panel3_Label2.Font = $FormA_Panel3_Label2_Font $FormA_Panel3_Label2.AutoSize = $True $FormA_Panel3_Label2.BackColor = "Transparent" $FormA_Panel3_Label2.ForeColor = "Window" $FormA_Panel3_Label2.Padding = $FormA_Panel3_Label2_Padding $FormA_Panel3_Label2.Text = $Lang.FormA_Panel3_Label2 $FormA_Panel3_Label2.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel3_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel3.Controls.Add($FormA_Panel3_Label2) $FormA_Panel3_Label2.Location = New-Object System.Drawing.Point(($FormA_Panel3.Width - $FormA_Panel3_Label2.Width - 50),360) #=========================================================================== # Begin Form Event III #=========================================================================== $FormA_Panel3_Label2.Add_MouseHover({ $FormA_Panel3_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $FormA.Cursor = [System.Windows.Forms.Cursors]::Hand }) $FormA_Panel3_Label2.Add_MouseLeave({ $FormA_Panel3_Label2.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA.Cursor = [System.Windows.Forms.Cursors]::Default }) $FormA_Panel3_Label2.Add_Click({ $Script:Install = $True If ($FormA_Panel3_Panel1_RadioButton1.Checked) { $Script:DeploymentType = "Guest" } Else { $Script:DeploymentType = "Host" } If ($FormA_Panel3_Panel2_RadioButton1.Checked) { $Script:Edition = "Standard" } Else { $Script:Edition = "Datacenter" } [System.Collections.ArrayList]$Script:Packages = @() Foreach ($in in $FormA_Panel3_CheckedListBox.CheckedIndices) { $Packages.Add("Microsoft-NanoServer-{0}-Package" -f $Packs[$in*2+1]) } $FormA.Close() }) #=========================================================================== # Begin PowerShell Part IV #=========================================================================== [void] $FormA.ShowDialog() If (-not $Install) { Exit } $Install = $False $FormA.Controls.Remove($FormA_Panel3) Remove-Variable -Name FormA_Panel3* -Force -ErrorAction SilentlyContinue -Confirm:$False #=========================================================================== # Begin Form Objects IV #=========================================================================== $Script:FormA_Panel4 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel4_Label0 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_Label0_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel4_Label0_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel4_TextBox_Font = New-Object System.Drawing.Font("Times New Roman",12,[System.Drawing.FontStyle]::Regular) $Script:FormA_Panel4_Label_Font = New-Object System.Drawing.Font("Times New Roman",13,[System.Drawing.FontStyle]::Italic) $Script:FormA_Panel4_TextBox1 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label1 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip1 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox2 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label2 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip2 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox3 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label3 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip3 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox4 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label4 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip4 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox5 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label5 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip5 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox6 = New-Object System.Windows.Forms.TextBox $Script:FormA_Panel4_Label6 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_ToolTip6 = New-Object System.Windows.Forms.ToolTip $Script:FormA_Panel4_TextBox4B = New-Object System.Windows.Forms.TextBox $FormA_Panel4.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel4.Size = New-Object System.Drawing.Size(700,450) $FormA_Panel4.BackColor = "Transparent" $FormA.Controls.Add($FormA_Panel4) $FormA_Panel4_Label0_Padding.All = 0 $FormA_Panel4_Label0.Font = $FormA_Panel4_Label0_Font $FormA_Panel4_Label0.AutoSize = $True $FormA_Panel4_Label0.BackColor = "Transparent" $FormA_Panel4_Label0.ForeColor = "Window" $FormA_Panel4_Label0.Padding = $FormA_Panel4_Label0_Padding $FormA_Panel4_Label0.Text = $Lang.FormA_Panel4_Label0 $FormA_Panel4_Label0.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4.Controls.Add($FormA_Panel4_Label0) $FormA_Panel4_Label0.Location = New-Object System.Drawing.Point((($FormA_Panel4.Width - $FormA_Panel4_Label0.Width)/2),10) $FormA_Panel4_Label1.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label1.AutoSize = $True $FormA_Panel4_Label1.BackColor = "Transparent" $FormA_Panel4_Label1.ForeColor = "Window" $FormA_Panel4_Label1.Text = $Lang.FormA_Panel4_Label1 $FormA_Panel4_Label1.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label1.Location = New-Object System.Drawing.Point(20,50) $FormA_Panel4_ToolTip1.settooltip($FormA_Panel4_Label1, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_Label1) $FormA_Panel4_TextBox1.Location = New-Object System.Drawing.Point($FormA_Panel4_Label1.Left,($FormA_Panel4_Label1.Top + $FormA_Panel4_Label1.Height)) $FormA_Panel4_TextBox1.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox1.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox1.MaxLength = 15 $FormA_Panel4_ToolTip1.settooltip($FormA_Panel4_TextBox1, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox1) $FormA_Panel4_Label2.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label2.AutoSize = $True $FormA_Panel4_Label2.BackColor = "Transparent" $FormA_Panel4_Label2.ForeColor = "Window" $FormA_Panel4_Label2.Text = $Lang.FormA_Panel4_Label2 $FormA_Panel4_Label2.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label2.Location = New-Object System.Drawing.Point(385,50) $FormA_Panel4_ToolTip2.settooltip($FormA_Panel4_Label2, $Lang.Mandatory) $FormA_Panel4.Controls.Add($FormA_Panel4_Label2) $FormA_Panel4_TextBox2.Location = New-Object System.Drawing.Point($FormA_Panel4_Label2.Left,($FormA_Panel4_Label2.Top + $FormA_Panel4_Label2.Height)) $FormA_Panel4_TextBox2.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox2.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox2.UseSystemPasswordChar = $True $FormA_Panel4_ToolTip2.settooltip($FormA_Panel4_TextBox2, $Lang.Mandatory) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox2) $FormA_Panel4_Label3.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label3.AutoSize = $True $FormA_Panel4_Label3.BackColor = "Transparent" $FormA_Panel4_Label3.ForeColor = "Window" $FormA_Panel4_Label3.Text = $Lang.FormA_Panel4_Label3 $FormA_Panel4_Label3.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label3.Location = New-Object System.Drawing.Point(20,120) $FormA_Panel4_ToolTip3.settooltip($FormA_Panel4_Label3, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_Label3) $FormA_Panel4_TextBox3.Location = New-Object System.Drawing.Point($FormA_Panel4_Label3.Left,($FormA_Panel4_Label3.Top + $FormA_Panel4_Label3.Height)) $FormA_Panel4_TextBox3.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox3.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox3.MaxLength = 15 $FormA_Panel4_ToolTip3.settooltip($FormA_Panel4_TextBox3, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox3) $FormA_Panel4_Label4.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label4.AutoSize = $True $FormA_Panel4_Label4.BackColor = "Transparent" $FormA_Panel4_Label4.ForeColor = "Window" $FormA_Panel4_Label4.Text = $Lang.FormA_Panel4_Label4 $FormA_Panel4_Label4.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label4.Location = New-Object System.Drawing.Point(20,190) $FormA_Panel4_ToolTip4.settooltip($FormA_Panel4_Label4, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_Label4) $FormA_Panel4_TextBox4.Location = New-Object System.Drawing.Point($FormA_Panel4_Label4.Left,($FormA_Panel4_Label4.Top + $FormA_Panel4_Label4.Height)) $FormA_Panel4_TextBox4.Size = New-Object System.Drawing.Size(50,24) $FormA_Panel4_TextBox4.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox4.MaxLength = 2 $FormA_Panel4_ToolTip4.settooltip($FormA_Panel4_TextBox4, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox4) $FormA_Panel4_TextBox4B.Location = New-Object System.Drawing.Point(80,($FormA_Panel4_Label4.Top + $FormA_Panel4_Label4.Height)) $FormA_Panel4_TextBox4B.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox4B.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox4B.MaxLength = 15 $FormA_Panel4_TextBox4B.TabStop = $False $FormA_Panel4_TextBox4B.ReadOnly = $True $FormA_Panel4_ToolTip4.settooltip($FormA_Panel4_TextBox4B, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox4B) $FormA_Panel4_Label5.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label5.AutoSize = $True $FormA_Panel4_Label5.BackColor = "Transparent" $FormA_Panel4_Label5.ForeColor = "Window" $FormA_Panel4_Label5.Text = $Lang.FormA_Panel4_Label5 $FormA_Panel4_Label5.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label5.Location = New-Object System.Drawing.Point(20,260) $FormA_Panel4_ToolTip5.settooltip($FormA_Panel4_Label5, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_Label5) $FormA_Panel4_TextBox5.Location = New-Object System.Drawing.Point($FormA_Panel4_Label5.Left,($FormA_Panel4_Label5.Top + $FormA_Panel4_Label5.Height)) $FormA_Panel4_TextBox5.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox5.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox5.MaxLength = 15 $FormA_Panel4_ToolTip5.settooltip($FormA_Panel4_TextBox5, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox5) $FormA_Panel4_Label6.Font = $FormA_Panel4_Label_Font $FormA_Panel4_Label6.AutoSize = $True $FormA_Panel4_Label6.BackColor = "Transparent" $FormA_Panel4_Label6.ForeColor = "Window" $FormA_Panel4_Label6.Text = $Lang.FormA_Panel4_Label6 $FormA_Panel4_Label6.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label6.Location = New-Object System.Drawing.Point(20,330) $FormA_Panel4_ToolTip6.settooltip($FormA_Panel4_Label6, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_Label6) $FormA_Panel4_TextBox6.Location = New-Object System.Drawing.Point($FormA_Panel4_Label6.Left,($FormA_Panel4_Label6.Top + $FormA_Panel4_Label6.Height)) $FormA_Panel4_TextBox6.Size = New-Object System.Drawing.Size(200,24) $FormA_Panel4_TextBox6.Font = $FormA_Panel4_TextBox_Font $FormA_Panel4_TextBox6.MaxLength = 15 $FormA_Panel4_ToolTip6.settooltip($FormA_Panel4_TextBox6, $Lang.Optional) $FormA_Panel4.Controls.Add($FormA_Panel4_TextBox6) $Script:FormA_Panel4_Label10 = New-Object System.Windows.Forms.Label $Script:FormA_Panel4_Label10_Padding = New-Object System.Windows.Forms.Padding $Script:FormA_Panel4_Label10_Font = New-Object System.Drawing.Font("Times New Roman",22,[System.Drawing.FontStyle]::Italic) $FormA_Panel4_Label10_Padding.Left = 50 $FormA_Panel4_Label10_Padding.Right = 50 $FormA_Panel4_Label10_Padding.Bottom = 5 $FormA_Panel4_Label10_Padding.Top = 5 $FormA_Panel4_Label10.Font = $FormA_Panel4_Label10_Font $FormA_Panel4_Label10.AutoSize = $True $FormA_Panel4_Label10.BackColor = "Transparent" $FormA_Panel4_Label10.ForeColor = "Window" $FormA_Panel4_Label10.Padding = $FormA_Panel4_Label10_Padding $FormA_Panel4_Label10.Text = $Lang.FormA_Panel4_Label10 $FormA_Panel4_Label10.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel4_Label10.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA_Panel4.Controls.Add($FormA_Panel4_Label10) $FormA_Panel4_Label10.Location = New-Object System.Drawing.Point(($FormA_Panel4.Width - $FormA_Panel4_Label10.Width - 50),360) #=========================================================================== # Begin Form Event IV #=========================================================================== $FormA_Panel4_Label10.Add_MouseHover({ $FormA_Panel4_Label10.BorderStyle = [System.Windows.Forms.BorderStyle]::FixedSingle $FormA.Cursor = [System.Windows.Forms.Cursors]::Hand }) $FormA_Panel4_Label10.Add_MouseLeave({ $FormA_Panel4_Label10.BorderStyle = [System.Windows.Forms.BorderStyle]::Fixed3D $FormA.Cursor = [System.Windows.Forms.Cursors]::Default }) $FormA_Panel4_Label10.Add_Click({ If (-not $FormA_Panel4_TextBox1.Text) { $FormA_Panel4_TextBox1.BackColor = "Window" } If (-not $FormA_Panel4_TextBox2.Text) { $FormA_Panel4_TextBox2.BackColor = "Red" } If (-not $FormA_Panel4_TextBox3.Text) { $FormA_Panel4_TextBox3.BackColor = "Window" } If (-not $FormA_Panel4_TextBox4.Text) { $FormA_Panel4_TextBox4.BackColor = "Window" } If (-not $FormA_Panel4_TextBox5.Text) { $FormA_Panel4_TextBox5.BackColor = "Window" } If (-not $FormA_Panel4_TextBox6.Text) { $FormA_Panel4_TextBox6.BackColor = "Window" } If ((-not $FormA_Panel4_TextBox3.Text) -and $FormA_Panel4_TextBox4.Text) { $FormA_Panel4_TextBox3.BackColor = "Red" } If ((-not $FormA_Panel4_TextBox4.Text) -and $FormA_Panel4_TextBox3.Text) { $FormA_Panel4_TextBox4.BackColor = "Red" } If ((-not $FormA_Panel4_TextBox3.Text) -and (-not $FormA_Panel4_TextBox4.Text) -and (($FormA_Panel4_TextBox5.Text) -or ($FormA_Panel4_TextBox6.Text))) { $FormA_Panel4_TextBox3.BackColor = "Red"; $FormA_Panel4_TextBox4.BackColor = "Red" } If ((1..6 | ForEach-Object { If (((Get-Variable -Name "FormA_Panel4_TextBox$_").Value).BackColor -eq "Window") {$True} } | Measure-Object).Count -eq 6) { If ($FormA_Panel4_TextBox3.Text) { $Script:Ipv4Address = $FormA_Panel4_TextBox3.Text } If ($FormA_Panel4_TextBox4.Text) { $Script:Ipv4SubnetMask = $FormA_Panel4_TextBox4B.Text } If ($FormA_Panel4_TextBox5.Text) { $Script:Ipv4Dns = $FormA_Panel4_TextBox5.Text } If ($FormA_Panel4_TextBox6.Text) { $Script:Ipv4Gateway = $FormA_Panel4_TextBox6.Text } If ($FormA_Panel4_TextBox1.Text) { $Script:ComputerName = $FormA_Panel4_TextBox1.Text } If ($FormA_Panel4_TextBox2.Text) { [System.Security.SecureString]$Script:AdministratorPassword = ConvertTo-SecureString -String $FormA_Panel4_TextBox2.Text -asPlainText -Force } $Script:Install = $True $FormA.Close() } }) $FormA_Panel4_TextBox1.Add_TextChanged({ #http://www.ietf.org/rfc/rfc1001.txt #http://www.ietf.org/rfc/rfc1002.txt #http://www.ietf.org/rfc/rfc952.txt #http://www.ietf.org/rfc/rfc1123.txt $NetBIOS_Disallowed_Characters = [Char]'\', [Char]'/', [Char]':', [Char]'*', [Char]'?', [Char]'"', [Char]'<', [Char]'>', [Char]'|' $DNS_Disallowed_Characters = [Char]",", [Char]'~', [Char]":", [Char]"!", [Char]'@', [Char]'#', [Char]'$', [Char]'%', [Char]'^', [Char]'&', [Char]"'", [Char]'.', [Char]'(', [Char]')', [Char]'{', [Char]'}', [Char]'_', [Char]' ' If ($FormA_Panel4_TextBox1.Text.ToCharArray() | ForEach-Object { If (($NetBIOS_Disallowed_Characters -contains $_) -or ($DNS_Disallowed_Characters -contains $_)) {$True} }) { $FormA_Panel4_TextBox1.BackColor = "Red" } Else { $FormA_Panel4_TextBox1.BackColor = "Window" } }) $FormA_Panel4_TextBox2.Add_TextChanged({ $FormA_Panel4_TextBox2.BackColor = "Window" }) $FormA_Panel4_TextBox3.Add_TextChanged({ $Allowed = [char]'0', [char]'1', [char]'2', [char]'3', [char]'4', [char]'5', [char]'6', [char]'7', [char]'8', [char]'9', [char]'.' $Count1 = ($FormA_Panel4_TextBox3.Text.ToCharArray() | ForEach-Object { If ($_ -eq ".") {$True} } | Measure-Object).Count $Count2 = ($FormA_Panel4_TextBox3.Text.Split(".") | ForEach-Object { If ($_) {$True} } | Measure-Object).Count $Count3 = ($FormA_Panel4_TextBox3.Text.Split(".") | ForEach-Object { If (([Int]$_ -ge 0) -and ([Int]$_ -le 255)) {$True} } | Measure-Object).Count $Check = $FormA_Panel4_TextBox3.Text.ToCharArray() | ForEach-Object { If ($Allowed -notcontains $_) {$True} } If ($Check -or ($Count1 -gt 3) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -ne 4))) { $FormA_Panel4_TextBox3.BackColor = "Red" } ElseIf ((-not $FormA_Panel4_TextBox3.Text) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -eq 4))) { $FormA_Panel4_TextBox3.BackColor = "Window" } Else { $FormA_Panel4_TextBox3.BackColor = "Gray" } }) $FormA_Panel4_TextBox4.Add_TextChanged({ $Allowed = [char]'0', [char]'1', [char]'2', [char]'3', [char]'4', [char]'5', [char]'6', [char]'7', [char]'8', [char]'9' $Check1 = $FormA_Panel4_TextBox4.Text.ToCharArray() | ForEach-Object { If ($Allowed -notcontains $_) {$True} } $Check2 = (([Int]$FormA_Panel4_TextBox4.Text -ge 1) -and ([Int]$FormA_Panel4_TextBox4.Text -le 32)) If ($Check1) { $FormA_Panel4_TextBox4.BackColor = "Red" } ElseIf ((-not $FormA_Panel4_TextBox4.Text) -or $Check2) { $FormA_Panel4_TextBox4.BackColor = "Window" $FormA_Panel4_TextBox4B.Text = ConvertTo-Mask -MaskLength ([Int]$FormA_Panel4_TextBox4.Text) } Else { $FormA_Panel4_TextBox4.BackColor = "Gray" } }) $FormA_Panel4_TextBox5.Add_TextChanged({ $Allowed = [char]'0', [char]'1', [char]'2', [char]'3', [char]'4', [char]'5', [char]'6', [char]'7', [char]'8', [char]'9', [char]'.' $Count1 = ($FormA_Panel4_TextBox5.Text.ToCharArray() | ForEach-Object { If ($_ -eq ".") {$True} } | Measure-Object).Count $Count2 = ($FormA_Panel4_TextBox5.Text.Split(".") | ForEach-Object { If ($_) {$True} } | Measure-Object).Count $Count3 = ($FormA_Panel4_TextBox5.Text.Split(".") | ForEach-Object { If (([Int]$_ -ge 0) -and ([Int]$_ -le 255)) {$True} } | Measure-Object).Count $Check = $FormA_Panel4_TextBox5.Text.ToCharArray() | ForEach-Object { If ($Allowed -notcontains $_) {$True} } If ($Check -or ($Count1 -gt 3) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -ne 4))) { $FormA_Panel4_TextBox5.BackColor = "Red" } ElseIf ((-not $FormA_Panel4_TextBox5.Text) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -eq 4))) { $FormA_Panel4_TextBox5.BackColor = "Window" } Else { $FormA_Panel4_TextBox5.BackColor = "Gray" } }) $FormA_Panel4_TextBox6.Add_TextChanged({ $Allowed = [char]'0', [char]'1', [char]'2', [char]'3', [char]'4', [char]'5', [char]'6', [char]'7', [char]'8', [char]'9', [char]'.' $Count1 = ($FormA_Panel4_TextBox6.Text.ToCharArray() | ForEach-Object { If ($_ -eq ".") {$True} } | Measure-Object).Count $Count2 = ($FormA_Panel4_TextBox6.Text.Split(".") | ForEach-Object { If ($_) {$True} } | Measure-Object).Count $Count3 = ($FormA_Panel4_TextBox6.Text.Split(".") | ForEach-Object { If (([Int]$_ -ge 0) -and ([Int]$_ -le 255)) {$True} } | Measure-Object).Count $Check = $FormA_Panel4_TextBox6.Text.ToCharArray() | ForEach-Object { If ($Allowed -notcontains $_) {$True} } If ($Check -or ($Count1 -gt 3) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -ne 4))) { $FormA_Panel4_TextBox6.BackColor = "Red" } ElseIf ((-not $FormA_Panel4_TextBox6.Text) -or (($Count1 -eq 3) -and ($Count2 -eq 4) -and ($Count3 -eq 4))) { $FormA_Panel4_TextBox6.BackColor = "Window" } Else { $FormA_Panel4_TextBox6.BackColor = "Gray" } }) #=========================================================================== # Begin PowerShell Part V #=========================================================================== [void] $FormA.ShowDialog() If (-not $Install) { Exit } $FormA.Controls.Remove($FormA_Panel4) Remove-Variable -Name FormA_Panel4* -Force -ErrorAction SilentlyContinue -Confirm:$False #=========================================================================== # Begin Form Objects V #=========================================================================== $Script:FormA_Panel5 = New-Object System.Windows.Forms.Panel $Script:FormA_Panel5_Label0 = New-Object System.Windows.Forms.Label $Script:FormA_Panel5_Label0_Font = New-Object System.Drawing.Font("Times New Roman",16,[System.Drawing.FontStyle]::Italic) $FormA_Panel5.Location = New-Object System.Drawing.Point(0,0) $FormA_Panel5.Size = New-Object System.Drawing.Size(700,450) $FormA_Panel5.BackColor = "Transparent" $FormA.Controls.Add($FormA_Panel5) $FormA_Panel5_Label0.Font = $FormA_Panel5_Label0_Font $FormA_Panel5_Label0.AutoSize = $True $FormA_Panel5_Label0.BackColor = "Transparent" $FormA_Panel5_Label0.ForeColor = "Window" $FormA_Panel5_Label0.Text = $Lang.FormA_Panel5_Label0 $FormA_Panel5_Label0.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter $FormA_Panel5.Controls.Add($FormA_Panel5_Label0) $FormA_Panel5_Label0.Location = New-Object System.Drawing.Point((($FormA_Panel5.Width - $FormA_Panel5_Label0.Width)/2),10) $Height = 0 1..5 | ForEach-Object { Set-Variable -Name "FormA_Panel5_Label$_" -Value (New-Object System.Windows.Forms.Label) Set-Variable -Name "FormA_Panel5_Font$_" -Value (New-Object System.Drawing.Font("Times New Roman",13,[System.Drawing.FontStyle]::Regular)) ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Font = (Get-Variable -Name "FormA_Panel5_Font$_").Value ((Get-Variable -Name "FormA_Panel5_Label$_").Value).AutoSize = $True ((Get-Variable -Name "FormA_Panel5_Label$_").Value).BackColor = "Transparent" ((Get-Variable -Name "FormA_Panel5_Label$_").Value).ForeColor = "Window" ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Text = $Lang."FormA_Panel5_Label$_" ((Get-Variable -Name "FormA_Panel5_Label$_").Value).TextAlign = [System.Drawing.ContentAlignment]::MiddleLeft ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Location = New-Object System.Drawing.Point(60,(100 + $Height)) $FormA_Panel5.Controls.Add((Get-Variable -Name "FormA_Panel5_Label$_").Value) $Height += 40 } #=========================================================================== # Begin Form Event V #=========================================================================== $FormA.Add_Shown({ Sleep -Seconds 2 $Script:FormA_Panel5_Labelx_Font = New-Object System.Drawing.Font("Times New Roman",13,[System.Drawing.FontStyle]::Bold) $Script:Path_Base = $Disk_List_Spare[1] + ":\TEMP\BASE\" $Script:Path_Target = $Disk_List_Spare[1] + ":\TEMP\nano.wim" $Script:Path_TEMP = $Disk_List_Spare[1] + ":\TEMP" $Script:Path_Windows = $Disk_List_Spare[1] + ":\Windows" $Script:Path_System = $Disk_List_Spare[0] + ":" $Script:Path_Destination = $Disk_List_Spare[1] + ":\" $Object = @{ 'DeploymentType' = $DeploymentType 'Edition' = $Edition 'MediaPath' = $Path 'BasePath' = $Path_Base 'TargetPath' = $Path_Target 'AdministratorPassword' = $AdministratorPassword 'Verbose' = $true; } If ($Packages) { $Object.Add('Packages', $Packages) } If ($ComputerName) { $Object.Add('ComputerName', $ComputerName) } If ($DomainName) { $Object.Add('DomainName', $DomainName) } If ($Ipv4Address) { $Object.Add('Ipv4Address', $Ipv4Address); $Object.Add('InterfaceNameOrIndex', $Ethernet) } If ($Ipv4SubnetMask) { $Object.Add('Ipv4SubnetMask', $Ipv4SubnetMask) } If ($Ipv4Gateway) { $Object.Add('Ipv4Gateway', $Ipv4Gateway) } If ($Ipv4Dns) { $Object.Add('Ipv4Dns', $Ipv4Dns) } If ($EnableRemoteManagementPort) { $Object.Add('EnableRemoteManagementPort', $true) } Import-Module ($Path_NanoServer + "NanoServerImageGenerator\NanoServerImageGenerator.psm1") | Out-Null Import-Module -Name Dism -Verbose | Out-Null 1..5 | ForEach-Object { ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Text = ">> " + ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Text Sleep -Seconds 1 switch ($_) { 1 { Get-Disk -Number $Disk_Number | Clear-Disk -RemoveData -RemoveOEM -Confirm:$False -ErrorAction SilentlyContinue | Out-Null Get-Disk -Number $Disk_Number | Initialize-Disk -PartitionStyle $Bios_Type_Name -Confirm:$False -ErrorAction SilentlyContinue | Out-Null } 2 { If ($Bios_Type_Name -eq "MBR") { Get-Disk -Number $Disk_Number | New-Partition -Size 350MB -DriveLetter $Disk_List_Spare[0] -IsActive | Format-Volume -FileSystem NTFS -NewFileSystemLabel "System" | Out-Null Get-Disk -Number $Disk_Number | New-Partition -UseMaximumSize -DriveLetter $Disk_List_Spare[1] | Format-Volume -FileSystem NTFS -NewFileSystemLabel "NanoServer" | Out-Null } Else { Get-Disk -Number $Disk_Number | New-Partition -Size 350MB -DriveLetter $Disk_List_Spare[0] -GptType '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}' | Format-Volume -FileSystem FAT32 -NewFileSystemLabel "System" | Out-Null Get-Disk -Number $Disk_Number | New-Partition -UseMaximumSize -DriveLetter $Disk_List_Spare[1] -GptType '{ebd0a0a2-b9e5-4433-87c0-68b6b72699c7}' | Format-Volume -FileSystem NTFS -NewFileSystemLabel "NanoServer" | Out-Null } } 3 { New-Item -ItemType Directory -Path $Path_Base -Force -Confirm:$False -ErrorAction SilentlyContinue | Out-Null New-NanoServerImage @Object } 4 { Expand-WindowsImage -ImagePath $Path_Target -Index 1 -ApplyPath $Path_Destination } 5 { & "$env:windir\System32\bcdboot.exe" $Path_Windows /s $Path_System Remove-Item -Path $Path_TEMP -Force -Recurse -Confirm:$False -ErrorAction SilentlyContinue | Out-Null $FormA.Close() } default {} } ((Get-Variable -Name "FormA_Panel5_Label$_").Value).Font = $FormA_Panel5_Labelx_Font Sleep -Seconds 1 } }) #=========================================================================== # Begin PowerShell Part VI #=========================================================================== [void] $FormA.ShowDialog() <# New-NanoServerImage [-DeploymentType] {Host | Guest} [-Edition] {Standard | Datacenter} -TargetPath -AdministratorPassword [-MediaPath ] [-BasePath ] [-MaxSize ] [-Storage] [-Compute] [-Defender] [-Clustering] [-OEMDrivers] [-Containers] [-Packages ] [-ServicingPackages ] [-ComputerName ] [-UnattendPath ] [-DomainName ] [-DomainBlobPath ] [-ReuseDomainNode] [-DriversPath ] [-InterfaceNameOrIndex ] [-Ipv6Address ] [-Ipv6Dns ] [-Ipv4Address ] [-Ipv4SubnetMask ] [-Ipv4Gateway ] [-Ipv4Dns ] [-DebugMethod {Serial | Net | 1394 | USB}] [-EnableEMS] [-EMSPort ] [-EMSBaudRate ] [-EnableRemoteManagementPort] [-CopyFiles ] [-SetupCompleteCommands ] [-RamdiskBoot] [-Development] [] -------------------------------------------------------------- Accessing Nano Server over a serial port with Emergency Management Services -EnableEMS -EMSPort 3 -EMSBaudRate 9600 -EMSBaudRate Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -EMSPort Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -EnableEMS Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -------------------------------------------------------------- Connecting with WinRM To be able to connect to a Nano Server computer using Windows Remote Management (WinRM) (from another computer that is not on the same subnet), open port 5985 for inbound TCP traffic on the Nano Server image. Use this cmdlet: -EnableRemoteManagementPort Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -------------------------------------------------------------- -Ipv6Address Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -Ipv6Dns Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -------------------------------------------------------------- -MaxSize Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false -RamdiskBoot Obligatoire ? false Position ? Nommé Accepter l'entrée de pipeline ? false Nom du jeu de paramètres (Tout) Alias Aucun(e) Dynamique ? false #>