Add-Type -assembly System.Windows.Forms $main_form = New-Object System.Windows.Forms.Form $main_form.Text ='Create a USB Key' $main_form.Width = 600 $main_form.Height = 400 $main_form.AutoSize = $true $PathLabel = New-Object System.Windows.Forms.Label $PathLabel.Text = "Path to Wimfile:" $PathLabel.Location = New-Object System.Drawing.Point(20,10) $PathLabel.AutoSize = $true $PathText = New-Object System.Windows.Forms.TextBox $PathText.Width = 278 $PathText.Location = New-Object System.Drawing.Point(200,8) $PathText.Text = "C:\temp\Boot\amd64\boot.wim" $PathBtn = new-Object System.Windows.Forms.Button $PathBtn.Location = New-Object System.Drawing.Point(480,8) $PathBtn.Width = 20 $PathBtn.Height = $PathText.Height $PathBtn.text = "..." $PathBtn.Add_Click( { $fileBrowser = New-Object System.Windows.Forms.OpenFileDialog $fileBrowser.FileName = $PathText.Text $fileBrowser.InitialDirectory = Split-Path $PathText.Text -Parent if ($fileBrowser.ShowDialog() = [System.Windows.Forms.DialogResult]::OK) { $PathText.Text = $fileBrowser.FileName } } ) $ARCHLabel = New-Object System.Windows.Forms.Label $ARCHLabel.Text = "Processor Architecture (ARCH):" $ARCHLabel.Location = New-Object System.Drawing.Point(20,40) $ARCHLabel.AutoSize = $true $ARCHComboBox = New-Object System.Windows.Forms.ComboBox $ARCHComboBox.Width = 300 $ARCHComboBox.Items.Add("X86"); $ARCHComboBox.Items.Add("amd64"); $ARCHComboBox.SelectedItem= "amd64"; $ARCHComboBox.Location = New-Object System.Drawing.Point(200,38) $URLLabel = New-Object System.Windows.Forms.Label $URLLabel.Text = "Deployment URL:" $URLLabel.Location = New-Object System.Drawing.Point(20,70) $URLLabel.AutoSize = $true $URLText = New-Object System.Windows.Forms.TextBox $URLText.Width = 300 $URLText.Location = New-Object System.Drawing.Point(200,68) $URLText.Text ="http://:port/ciosdeploy" $WorkingLabel = New-Object System.Windows.Forms.Label $WorkingLabel.Text = "Temporary Working Folder:" $WorkingLabel.Location = New-Object System.Drawing.Point(20,100) $WorkingLabel.AutoSize = $true $WorkingText = New-Object System.Windows.Forms.TextBox $WorkingText.Width = 278 $WorkingText.Location = New-Object System.Drawing.Point(200,98) $WorkingText.Text = "c:\temp\working" $PathBtn2 = new-Object System.Windows.Forms.Button $PathBtn2.Location = New-Object System.Drawing.Point(480,98) $PathBtn2.Width = 20 $PathBtn2.Height = $PathText.Height $PathBtn2.text = "..." $PathBtn2.Add_Click( { $folderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog $folderBrowser.SelectedPath = $WorkingText.Text if ($folderBrowser.ShowDialog() = [System.Windows.Forms.DialogResult]::OK) { $WorkingText.Text = $folderBrowser.SelectedPath } } ) $ProgressLabel = New-Object System.Windows.Forms.Label $ProgressLabel.Location = New-Object System.Drawing.Point(20,140) $ProgressLabel.Width = 300 $BuildBtn = new-Object System.Windows.Forms.Button $BuildBtn.Location = New-Object System.Drawing.Point(428,128) $BuildBtn.Width = 72 $BuildBtn.Height = $PathText.Height $BuildBtn.text = "Build" $BuildBtn.Add_Click( { $ProgressLabel.Text = "Building...." $WimFile = $PathText.Text $WINPE_ARCH = $ARCHComboBox.SelectedItem $Url = $URLText.Text $WorkingFolder = $WorkingText.Text Write-Host $WimFile Write-Host $WINPE_ARCH Write-Host $Url Write-Host $WorkingFolder if([System.IO.Directory]::Exists($WorkingFolder)){ Remove-Item $WorkingFolder -Recurse -Confirm } # ese {l #New-Item -ItemType directory -Path $WorkingFolder #} copype.cmd $WINPE_ARCH $WorkingFolder New-Item -Path $WorkingFolder"\media\sources" -ItemType "directory" -Force Copy-Item -Path $WimFile -Destination $WorkingFolder"\media\sources\boot.wim" $Disk = Get-Disk | Where-Object BusType -eq USB | Out-GridView -Title 'Select USB Drive to Format' -OutputMode Single Clear-Disk -Number $Disk.Number -RemoveData -RemoveOEM -Confirm:$true # -PassThru $BootDrive = New-Partition -DiskNumber $Disk.Number -Size:1024MB -IsActive -AssignDriveLetter | Format-Volume -FileSystem FAT32 $CiRepo = New-Partition -DiskNumber $Disk.Number -UseMaximumSize -AssignDriveLetter| Format-Volume -FileSystem NTFS -NewFileSystemLabel CIREPO MakeWinPEMedia.cmd /UFD /f $WorkingFolder "$($BootDrive.DriveLetter):" Install-Module PsIni -Scope AllUsers -RequiredVersion 3.1.2 -Force -Confirm:$false Import-Module PsIni -RequiredVersion 3.1.2 -Force New-Item -Path "$($BootDrive.DriveLetter):\" -Name "OSDBootStrap" -ItemType "directory" $ciOSDeploy = @{“app”=”files/application/osdclient”} $DeploymentServerURLs = @{“Test”=$Url} $DeploymentServer = @{“ciOSDeploy”=$ciOSDeploy;”DeploymentServerURLs”=$DeploymentServerURLs} Out-IniFile -InputObject $DeploymentServer -FilePath "$($BootDrive.DriveLetter):\OSDBootStrap\DeploymentServer.ini" $ProgressLabel.Text = "Done!" } ) $main_form.Controls.Add($PathLabel) $main_form.Controls.Add($PathText) $main_form.Controls.Add($PathBtn) $main_form.Controls.Add($ARCHLabel) $main_form.Controls.Add($ARCHComboBox) $main_form.Controls.Add($URLLabel) $main_form.Controls.Add($URLText) $main_form.Controls.Add($WorkingLabel) $main_form.Controls.Add($WorkingText) $main_form.Controls.Add($PathBtn2) $main_form.Controls.Add($BuildBtn) $main_form.Controls.Add($ProgressLabel) $main_form.ShowDialog()