#------------------------------------------------------------------------ # Source File Information (DO NOT MODIFY) # Source ID: 0c7d2417-dd03-4616-9091-36d6ca7be735 # Source File: essai.psf #------------------------------------------------------------------------ #region File Recovery Data (DO NOT MODIFY) <#RecoveryData: qgIAAB+LCAAAAAAABABlkkmL4lAAhO8B/4P0tWHSL5sRbCH71tG8bBpvWV5iNIvmmfXXT9PDwMDU qaiiLsW3c1HaDqib5fgVr78NLtvm843+9fG2XxHr9e7YlUXZxJVaVugQ12iPMI7LXw+c78j/up+F 2nb1HsyGtLE54I9QEMT3L0n4I1GQQKgCp1iEIPfzyVncrfkaIhVgyRTYLHrM3GzOjsdoHXiElBWc 1TNFsrXYXVbEVczkj8Gr2e20UM1Rzt2eh1bhbUmoGAnGd/tBMZpAepOvNDC3DFI7ZceLNPXhs1UO ulg9Zd+6FUsn+ytiXngZeZX/hJ4OufYewUv8KLQb44Z3a6Oom8I7uUFyjbXpKH44rR9HUeqaHRvk 2cLDNrcifL8+dSfVwhWhSot4DcArkxpVfvqWhc3Ls4W5UiTNQYhRvZUhjnS7yOgMsn3796GgdPRo 8hi+r3VzgA0cHbAiJiq6cUE8UBLVg/aajclgDWnJyB1gQNaGSakaoXNOWb3fnNilb1MwLZVViQ5J Q+MgsXhrcMz7qEiquyJOV25T1XWBw3BT1ofhbNVgNFP3VB6zSAeejF2puGM0+i8KUTR0o9trycaG MSrm8c6ntn0zM05WzWPorAhKpU318ASng3030+msRfZFShCKFAOxJJ+aNzpk8uSLt6I2H0HwYueW r/PpjGa6zLHpiV8pUHjlG4fPHfmDyw84AsaoTqoS4TX5nezIf9nc/waoep87qgIAAA==#> #endregion <# .NOTES -------------------------------------------------------------------------------- Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2018 v5.5.149 Generated on: 08/08/2018 18:25 Generated by: Administrator -------------------------------------------------------------------------------- .DESCRIPTION GUI script generated by PowerShell Studio 2018 #> #---------------------------------------------- #region Application Functions #---------------------------------------------- #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Show-essai_psf { #---------------------------------------------- #region Import the Assemblies #---------------------------------------------- [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') #endregion Import Assemblies #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $form1 = New-Object 'System.Windows.Forms.Form' $button1 = New-Object 'System.Windows.Forms.Button' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' #endregion Generated Form Objects #---------------------------------------------- # User Generated Script #---------------------------------------------- $form1_Load={ #TODO: Initialize Form Controls here } $button1_Click={ #TODO: Place custom script here Add-Type -AssemblyName Microsoft.VisualBasic $DNSName = [Microsoft.VisualBasic.Interaction]::InputBox("For example : example.local", "Enter Domain Name DNS") $NameNetbiosDxx = [Microsoft.VisualBasic.Interaction]::InputBox("For example : example", "Enter Entity Name") $FeatureList = @("RSAT-AD-Tools", "AD-Domain-Services", "DNS") Foreach ($Feature in $FeatureList) { if (((Get-WindowsFeature -Name $Feature).InstallState) -eq "Available") { Add-Type -AssemblyName PresentationFramework [System.Windows.MessageBox]::Show("$Feature will be installed now !") Try { Add-WindowsFeature -Name $Feature -IncludeManagementTools Add-Type -AssemblyName PresentationFramework [System.Windows.MessageBox]::Show("$Feature : Installation is a success !") } Catch { Add-Type -AssemblyName PresentationFramework [System.Windows.MessageBox]::Show("$Feature : Error during installation !") } } # if(((Get-WindowsFeature -Name $Feature).InstallState) -eq "Available") } # Foreach($Feature in $FeatureList) $DomainNameDNS = $DNSName $DomainNameNetbios = "$NameNetbiosDxx" $ForestConfiguration = @{ '-SafeModeAdministratorPassword' = (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force); '-DatabasePath' = 'C:\Windows\NTDS'; '-DomainMode' = 'Default'; '-DomainName' = $DomainNameDNS; '-DomainNetbiosName' = $DomainNameNetbios; '-ForestMode' = 'Default'; '-InstallDns' = $true; '-LogPath' = 'C:\Windows\NTDS'; '-NoRebootOnCompletion' = $false; '-SysvolPath' = 'C:\Windows\SYSVOL'; '-Force' = $true; '-CreateDnsDelegation' = $false } Import-Module ADDSDeployment Install-ADDSForest @ForestConfiguration } # --End User Generated Script-- #---------------------------------------------- #region Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $form1.WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed= { #Remove all event handlers from the controls try { $button1.remove_Click($button1_Click) $form1.remove_Load($form1_Load) $form1.remove_Load($Form_StateCorrection_Load) $form1.remove_FormClosed($Form_Cleanup_FormClosed) } catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- $form1.SuspendLayout() # # form1 # $form1.Controls.Add($button1) $form1.AutoScaleDimensions = '6, 13' $form1.AutoScaleMode = 'Font' $form1.ClientSize = '284, 261' $form1.Name = 'form1' $form1.Text = 'Form' $form1.add_Load($form1_Load) # # button1 # $button1.Location = '71, 67' $button1.Name = 'button1' $button1.Size = '75, 23' $button1.TabIndex = 0 $button1.Text = 'button1' $button1.UseCompatibleTextRendering = $True $button1.UseVisualStyleBackColor = $True $button1.add_Click($button1_Click) $form1.ResumeLayout() #endregion Generated Form Code #---------------------------------------------- #Save the initial state of the form $InitialFormWindowState = $form1.WindowState #Init the OnLoad event to correct the initial state of the form $form1.add_Load($Form_StateCorrection_Load) #Clean up the control events $form1.add_FormClosed($Form_Cleanup_FormClosed) #Show the Form return $form1.ShowDialog() } #End Function #Call the form Show-essai_psf | Out-Null