У меня есть папка, содержащая какой-то файл в 2 разных форматах. ISO и WMI. Прежде чем я отфильтрую папку с учетом формата расширения, мне нужно сопоставить папку с выбранным SWPOS. Это работает с моим кодом. Но мне нужно использовать radiobutton, чтобы отфильтровать папку, которая будет отображаться в флажке. если пользователь установит переключатель ISO, в этом поле будет отображаться только папка, содержащая файл расширения ISO. Я пытаюсь это сделать, но все еще застрял в радиокнопке. Любой может помочь, пожалуйста.
$SWPOPath = ".\files"
$ImagePath = ".\Image"
# GUI Handler
#============================================#
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object System.Windows.Forms.Form
$Form.MaximizeBox = $false
$Form.text = "Automation"
$Form.FormBorderStyle = 'FixedDialog'
$Form.StartPosition = "CenterScreen"
$Form.BackColor = "#F5F5F5 "
$Form.WindowState = 'Maximized'
$Form.SizeGripStyle = 'Hide'
$Form.controlbox = $true
$Label1 = New-Object system.Windows.Forms.Label
$Label1.text = "Please Select The SW:"
$label1.AutoSize = $true
$Title = New-Object system.Windows.Forms.Label
$Title.text = "AUTO"
$Title.ForeColor = "#0095d9"
$Form.Controls.Add($Title)
$Combo = New-Object system.Windows.Forms.ComboBox
$Combo.AutoSize = $true
$Combo.DropDownStyle = "DropDownList"
$Combo.Items.AddRange(@(Get-ChildItem -File $SWPOPath).Name)
$SelectedFile= {
$Global:SWPOSelected = $Combo.SelectedItem
Write-Host "SWPO Selected: $SWPOSelected"
$Global:GetSWPO = Get-ChildItem -Path $SWPOPath\$SWPOSelected
$Global:ReadSWPO = Get-Content -Path $SWPOPath\$SWPOSelected
$PFX = Get-Content -Path $SWPOPath\$SWPOSelected | Where-Object {$_ -like "*;ML_Prefix*"}
$Prefix = $PFX.Substring(11,3)
Write-Host "Prefix: $Prefix"
$BID = (Get-Content -Path $SWPOPath\$SWPOSelected | Where-Object {$_ -like "*;Build_ID*"}).Substring(10,11)
Write-Host "BuildID: $BID"
if(!(Test-Path -Path "$ImagePath\$Prefix$BID"))
{
[System.Windows.Forms.MessageBox]::Show("Image not available. Try again!","[Error]" , "OK", "Error")
}
else{
$files = [Collections.ArrayList]@(Get-ChildItem -Path "$ImagePath\$Prefix$BID" -Directory)
$checkedListBox.DataSource = $files
$checkedListBox.DisplayMember = 'Name'
$ButtonDeploy.Visible = $true
$ButtonDone.Visible = $true
$RadioButtonFFU.Visible = $true
$RadioButtonSFU.Visible = $true
$GMFormat.Visible = $true
}
}
$Combo.add_SelectedIndexChanged($SelectedFile)
$Combo.DisplayMember = 'Name'
$checkedListBox = New-Object System.Windows.Forms.CheckedListbox
$checkedListBox.CheckOnClick = $true
$checkedListBox.Enabled = $true
$checkedListBox.BackColor = "#F5F5F5"
$Form.Controls.Add($checkedListBox)
$Disk = New-Object system.Windows.Forms.ComboBox
$Disk.AutoSize = $true
$Disk.DropDownStyle = "DropDownList"
$Disk.Items.AddRange((Get-PhysicalDisk | Where-Object -FilterScript {($_.Bustype -ne "USB") -and ([long]$_.Size -ge 32gb)} | Select -ExpandProperty DeviceID))
$SelectedFile = {
$DiskSelected = $Disk.SelectedItem
Write-Host "Disk Selected: $DiskSelected"
$TextBox1.Text = @(Get-PhysicalDisk | Where-Object -FilterScript {$_.DeviceID -Eq "$DiskSelected"} | Select FriendlyName, BusType, MediaType, Size | Format-List | Out-String)
}
$Disk.add_SelectedIndexChanged($SelectedFile)
$Disk.DisplayMember = 'Name'
$TextBox1 = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline = $true
$TextBox1.WordWrap = $true
$TextBox1.BackColor = "#F5F5F5"
$TextBox1.Scrollbars = "Vertical"
$TextBox1.ReadOnly = $true
$ButtonDeploy = New-Object System.Windows.Forms.Button
$ButtonDeploy.Text = "Deploy"
$ButtonDeploy.BackColor = "#0095d9"
$ButtonDeploy.ForeColor = "#ffffff"
$ButtonDeploy.FlatStyle = 1
$ButtonDeploy.Visible = $false
$ButtonDeploy.Add_Click({
$UserResponse = [System.Windows.Forms.MessageBox]::Show("Are you sure to continue to deployment process?","[Message]" , "4", "Question")
if ($UserResponse -eq "YES" )
{
$Global:GetImage = ($CheckedListBox.CheckedItems).Name
$GetImage | Out-File ".\ImageSelected.txt" -Force
$ImageSelected = Get-Content .\ImageSelected.txt
$Global:GetImageFile = Get-ChildItem -Path "$ImagePath\*\*$ImageSelected*"
# if image does not select
if($ImageSelected -eq $null)
{
[System.Windows.MessageBox]::Show("You do not select the image!", "[Warning]", "0", "Warning")
}
else{
# if disk does not select
$Global:DiskSelected = $Disk.SelectedItem
if ($DiskSelected -eq $null)
{
[System.Windows.MessageBox]::Show("You do not select the disk number!", "[Warning]", "0", "Warning")
}
else{
Write-Host "Image Selected: $ImageSelected"
Write-Host "`n"
Write-Host "Disk Selected: $DiskSelected"
Write-Host "`n"
$DiskNameSelected = Get-PhysicalDisk | Where-Object -FilterScript {$_.DeviceID -Eq "$DiskSelected"} | Select -ExpandProperty FriendlyName
$MessageBody = "The Following Information Were Selected:`n`n`PO File: $SWPOSelected`n`n`Image File: $ImageSelected`n`n`Disk Name: $DiskNameSelected"
[System.Windows.MessageBox]::Show("$MessageBody", "[Message]", "0", "Information")
[System.Windows.MessageBox]::Show("Disk will be wiped and all data will be erased!", "[Warning!]", "0", "Warning")
[System.Windows.MessageBox]::Show("Starting deployment process....", "[Message]", "0", "Information")
# Output The Information To File
$Global:SWPOSelected = $Combo.SelectedItem | Out-File .\SWPOSelected.txt -Force
$Global:DiskSelected = $Disk.SelectedItem | Out-File .\DiskSelected.txt -Force
$Form.Close()
}
}
}
else
{
# UserRespon is NO
# No activity, continue select the spwo and image
}
})
$Form.Controls.Add($ButtonDeploy)
$ButtonDone = New-Object System.Windows.Forms.Button
$ButtonDone.Text = "Reboot"
$ButtonDone.BackColor = "#0095d9"
$ButtonDone.ForeColor = "#ffffff"
$ButtonDone.FlatStyle = 1
$ButtonDone.Add_Click({
$UserResponse_2 = [System.Windows.Forms.MessageBox]::Show("Are you sure to close the AutoGM Deploy window and reboot?","Message" , "4", "Question")
if ($UserResponse_2 -eq "YES" )
{
Write-Host "Restart-Computer"
# Restart-Computer
$Form.Close()
}
else{
# UserRespon is NO
# Continue activity
}
})
$ButtonDone.Visible = $false
$ButtonRefresh = New-Object system.Windows.Forms.Button
$ButtonRefresh.BackColor = "#0095d9"
$ButtonRefresh.ForeColor = "#ffffff"
$ButtonRefresh.text = "Refresh"
$ButtonRefresh.Add_Click({
# Remove all items from the ComboBox
$Combo.Items.Clear()
# Repopulate the ComboBox, just like when it was created
$Combo.Items.AddRange(@(Get-ChildItem -File $SWPOPath).Name)
})
$ButtonRefresh.FlatStyle = 1
$RadioButtonFFU = New-Object system.Windows.Forms.RadioButton
$RadioButtonFFU.text = "ISO"
$RadioButtonFFU.Visible = $false
$RadioButtonSFU = New-Object system.Windows.Forms.RadioButton
$RadioButtonSFU.text = "WMI"
$RadioButtonSFU.Visible = $false
$GMFormat = New-Object system.Windows.Forms.Label
$GMFormat.text = "Please Select The Format"
$GMFormat.AutoSize = $true
$GMFormat.Visible = $false
$Groupbox1 = New-Object system.Windows.Forms.Groupbox
$Groupbox1.text = "Images Available:"
$Groupbox1.AutoSize = $true
$Form.Controls.Add($Groupbox1)
$Groupbox2 = New-Object system.Windows.Forms.Groupbox
$Groupbox2.text = "SWPOs Available:"
$Groupbox2.AutoSize = $true
$Form.Controls.Add($Groupbox2)
$Groupbox3 = New-Object system.Windows.Forms.Groupbox
$Groupbox3.text = "Disks Available:"
$Groupbox3.AutoSize = $true
$Form.Controls.Add($Groupbox3)
$Label2 = New-Object system.Windows.Forms.Label
$Label2.text = "Please Select Disk Number:"
$Label2.AutoSize = $true
$ButtonRefresh2 = New-Object system.Windows.Forms.Button
$ButtonRefresh2.BackColor = "#0095d9"
$ButtonRefresh2.ForeColor = "#ffffff"
$ButtonRefresh2.text = "Refresh"
$ButtonRefresh2.Add_Click({
# Remove all items from the ComboBox
$Disk.Items.Clear()
$TextBox1.Clear()
# Repopulate the ComboBox, just like when it was created
$Disk.Items.AddRange((Get-PhysicalDisk | Where-Object -FilterScript {($_.Bustype -ne "USB") -and ([long]$_.Size -ge 32gb)} | Select -ExpandProperty DeviceID))
})
$ButtonRefresh2.FlatStyle = 1
$Form.Add_Shown({$Form.Activate()})
[void] $Form.Show()
#---------------------------------------------------------------------------------------------------------------------------------#
Function Smaller_768
{
#
# image
#
Write-Host "Screen height smaller than or equal to 768 px"
$font_size = ($width / 96)
$font_size
$Font = New-Object System.Drawing.Font("Segoe UI",$font_size,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font
$Form.AutoScaleMode = "Font"
$w_chk = $width / 2.9
$h_chk = $Height / 1.4
$h_bd = $h_chk + 40
$loc_gb1 = $w_chk / 1.08
$checkedListBox.Location = New-Object System.Drawing.Size(5,50)
$checkedListBox.Size = New-Object System.Drawing.Size($w_chk,$h_chk)
$Groupbox1.Location = New-Object System.Drawing.Size($loc_gb1,90)
$Groupbox1.Controls.AddRange(@($checkedListBox, $Label2))
#--------------------------------------------------------------------------
#
# SWPO
#
$w_com = $w_chk / 1.3
$Combo.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Combo.Location = New-Object System.Drawing.Size(5,60)
$loc_gb2 = $w_chk / 30
$Groupbox2.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox2.Controls.AddRange(@($Label1, $Combo,$ButtonRefresh))
$Label1.Location = New-Object System.Drawing.Size(5,35)
$loc_btr = $w_com / 2.5
$ButtonRefresh.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh.AutoSize = $true
$ButtonRefresh.Size = New-Object System.Drawing.Size(80,30)
#--------------------------------------------------------------------------
#
# DISK
#
$w_com = $w_chk / 1.3
$Disk.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Disk.Location = New-Object System.Drawing.Size(5,100)
$loc_gb2 = $w_chk + 370
$Groupbox3.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox3.Controls.AddRange(@($Label2, $Disk, $ButtonRefresh2, $ButtonDeploy, $ButtonDone, $TextBox1))
$Label2.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.5
$ButtonRefresh2.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh2.AutoSize = $true
$btd_loc = $w_com / 12
$ButtonDeploy.Location = New-Object System.Drawing.Size($btd_loc,$h_bd)
$ButtonDeploy.AutoSize = $true
$h_bd = $h_chk + 40
$btdo_loc = $w_com / 1.4
$ButtonDone.Location = New-Object System.Drawing.Size($btdo_loc,$h_bd)
$ButtonDone.AutoSize = $true
$w_txt = $w_chk / 1.1
$TextBox1.Location = New-Object System.Drawing.Size(5,200)
$TextBox1.Size = New-Object System.Drawing.Size($w_com,$w_txt)
$l_title = $width / 2.5
$font_title = ($width / 50)
$Title.Location = New-Object System.Drawing.Size($l_title,20)
$Title.AutoSize = $true
$Title_Font = New-Object System.Drawing.Font("Segoe UI",$font_title,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Pixel)
$Title.Font = $Title_Font
$Form.Controls.Add($Title)
}
Function Larger_768
{
#
# Image
#
Write-Host "Screen height larger than 768 px, less than 992px and Screen height larger than 992 px"
$font_size = ($width / 96)
$Font = New-Object System.Drawing.Font("Segoe UI",$font_size,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font
$Form.AutoScaleMode = "Font"
$w_chk = $width / 1.9
$h_chk = $Height / 0.88
$h_bd = $h_chk + 40
$loc_gb1 = $w_chk / 1.3
$checkedListBox.Location = New-Object System.Drawing.Size(5,50)
$checkedListBox.Size = New-Object System.Drawing.Size($w_chk,$h_chk)
$Groupbox1.Location = New-Object System.Drawing.Size($loc_gb1,90)
$Groupbox1.Controls.AddRange(@($checkedListBox, $Label2))
#--------------------------------------------------------------------------
#
# SWPO
#
$w_com = $w_chk / 1.3
$Combo.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Combo.Location = New-Object System.Drawing.Size(5,60)
$loc_gb2 = $w_chk + 30
$Groupbox2.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox2.Controls.AddRange(@($Label1, $Combo,$ButtonRefresh))
$Label1.Location = New-Object System.Drawing.Size(5,35)
$loc_btr = $w_com / 2
$ButtonRefresh.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh.AutoSize = $true
$ButtonRefresh.Size = New-Object System.Drawing.Size(80,30)
#--------------------------------------------------------------------------
#
# DISK
#
$w_com = $w_chk / 1.2
$Disk.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Disk.Location = New-Object System.Drawing.Size(5,100)
$loc_gb2 = $w_chk + 680
$Groupbox3.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox3.Controls.AddRange(@($Label2, $Disk, $ButtonRefresh2, $ButtonDeploy, $ButtonDone, $TextBox1))
$Label2.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.2
$ButtonRefresh2.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh2.AutoSize = $true
$ButtonRefresh2.Size = New-Object System.Drawing.Size(80,30)
$btd_loc = $w_com / 7
$ButtonDeploy.Location = New-Object System.Drawing.Size($btd_loc,$h_bd)
$ButtonDeploy.AutoSize = $true
$h_bd = $h_chk + 60
$btdo_loc = $w_com / 1.3
$ButtonDone.Location = New-Object System.Drawing.Size($btdo_loc,$h_bd)
$ButtonDone.AutoSize = $true
$w_txt = $w_chk / 1.13
$TextBox1.Location = New-Object System.Drawing.Size(5,250)
$TextBox1.Size = New-Object System.Drawing.Size($w_com,$w_txt)
$l_title = $width / 2.4
$font_title = ($width / 50)
$Title.Location = New-Object System.Drawing.Size($l_title,20)
$Title.AutoSize = $true
$Title_Font = New-Object System.Drawing.Font("Segoe UI",$font_title,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Pixel)
$Title.Font = $Title_Font
$Form.Controls.Add($Title)
}
Function Larger_992
{
Write-Host "Screen height larger than 992 px"
#
# Image
#
$font_size = ($width / 96)
$Font = New-Object System.Drawing.Font("Segoe UI",$font_size,[System.Drawing.FontStyle]::Italic,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font
$Form.AutoScaleMode = "Font"
$w_chk = $width / 2.9
$h_chk = $Height / 1.33
$loc_gb1 = $w_chk / 1.1
$h_bd = $h_chk + 60
$checkedListBox.Location = New-Object System.Drawing.Size(5,130)
$checkedListBox.Size = New-Object System.Drawing.Size($w_chk,$h_chk)
#--------------------------------------------------------------------------
#
# GM Format
#
$RadioButtonFFU.Location = New-Object System.Drawing.Size(10,90)
$RadioButtonFFU.AutoSize = $true
$RadioButtonSFU.Location = New-Object System.Drawing.Size(100,90)
$RadioButtonSFU.AutoSize = $true
$GM_title = $w_chk / 70
$GMFormat.Location = New-Object System.Drawing.Size($GM_title,50)
$GMFormat.AutoSize = $true
$Groupbox1.Location = New-Object System.Drawing.Size($loc_gb1,90)
$Groupbox1.Controls.AddRange(@($checkedListBox, $Label2, $RadioButtonFFU, $RadioButtonSFU, $GMFormat))
#--------------------------------------------------------------------------
#
# SWPO
#
$w_com = $w_chk / 1.3
$Combo.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Combo.Location = New-Object System.Drawing.Size(5,100)
$loc_gb2 = $w_chk / 40
$Groupbox2.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox2.Controls.AddRange(@($Label1, $Combo,$ButtonRefresh))
$Label1.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.5
$ButtonRefresh.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh.AutoSize = $true
$ButtonRefresh.Size = New-Object System.Drawing.Size(80,30)
#--------------------------------------------------------------------------
#
# DISK
#
$w_com = $w_chk / 1.2
$Disk.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Disk.Location = New-Object System.Drawing.Size(5,100)
$loc_gb2 = $w_chk + 680
$Groupbox3.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox3.Controls.AddRange(@($Label2, $Disk, $ButtonRefresh2, $ButtonDeploy, $ButtonDone, $TextBox1))
$Label2.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.2
$ButtonRefresh2.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh2.AutoSize = $true
$ButtonRefresh2.Size = New-Object System.Drawing.Size(80,30)
$btd_loc = $w_com / 7
$ButtonDeploy.Location = New-Object System.Drawing.Size($btd_loc,$h_bd)
$ButtonDeploy.AutoSize = $true
$h_bd = $h_chk + 60
$btdo_loc = $w_com / 1.3
$ButtonDone.Location = New-Object System.Drawing.Size($btdo_loc,$h_bd)
$ButtonDone.AutoSize = $true
$w_txt = $w_chk / 1.13
$TextBox1.Location = New-Object System.Drawing.Size(5,250)
$TextBox1.Size = New-Object System.Drawing.Size($w_com,$w_txt)
$l_title = $width / 2.4
$font_title = ($width / 50)
$Title.Location = New-Object System.Drawing.Size($l_title,20)
$Title.AutoSize = $true
$Title_Font = New-Object System.Drawing.Font("Segoe UI",$font_title,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Pixel)
$Title.Font = $Title_Font
$Form.Controls.Add($Title)
}
Function Larger_1200
{
#
# Image
#
Write-Host "Screen height larger than 1200 px"
$font_size = ($width / 96)
$font_size
$Font = New-Object System.Drawing.Font("Segoe UI",$font_size,[System.Drawing.FontStyle]::Regular,[System.Drawing.GraphicsUnit]::Pixel)
$Form.Font = $Font
$w_chk = $width / 2.9
$h_chk = $Height / 1.2
$h_bd = $h_chk + 40
$loc_gb1 = $w_chk / 1.1
$checkedListBox.Location = New-Object System.Drawing.Size(5,50)
$checkedListBox.Size = New-Object System.Drawing.Size($w_chk,$h_chk)
$Groupbox1.Location = New-Object System.Drawing.Size($loc_gb1,120)
$Groupbox1.Controls.AddRange(@($checkedListBox, $Label2))
#------------------------------------------------------------------------------------------
#
# SWPO
#
$w_com = $w_chk / 1.3
$Combo.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Combo.Location = New-Object System.Drawing.Size(5,130)
$loc_gb2 = $w_chk / 40
$Groupbox2.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox2.Controls.AddRange(@($Label1, $Combo,$ButtonRefresh))
$Label1.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.5
$ButtonRefresh.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh.AutoSize = $true
#--------------------------------------------------------------------------
#
# DISK
#
$w_com = $w_chk / 1.2
$Disk.Size = New-Object System.Drawing.Size($w_com,$w_com)
$Disk.Location = New-Object System.Drawing.Size(5,130)
$loc_gb2 = $w_chk + 1350
$Groupbox3.Location = New-Object System.Drawing.Size($loc_gb2,90)
$Groupbox3.Controls.AddRange(@($Label2, $Disk, $ButtonRefresh2, $ButtonDeploy, $ButtonDone, $TextBox1))
$Label2.Location = New-Object System.Drawing.Size(5,50)
$loc_btr = $w_com / 2.2
$ButtonRefresh2.Location = New-Object System.Drawing.Size($loc_btr,$h_bd)
$ButtonRefresh2.AutoSize = $true
$ButtonRefresh2.Size = New-Object System.Drawing.Size(80,30)
$btd_loc = $w_com / 7
$ButtonDeploy.Location = New-Object System.Drawing.Size($btd_loc,$h_bd)
$ButtonDeploy.AutoSize = $true
$h_bd = $h_chk + 45
$btdo_loc = $w_com / 1.3
$ButtonDone.Location = New-Object System.Drawing.Size($btdo_loc,$h_bd)
$ButtonDone.AutoSize = $true
$w_txt = $w_chk / 1.13
$TextBox1.Location = New-Object System.Drawing.Size(5,350)
$TextBox1.Size = New-Object System.Drawing.Size($w_com,$w_txt)
$l_title = $width / 2.3
$font_title = ($width / 50)
$Title.Location = New-Object System.Drawing.Size($l_title,20)
$Title.AutoSize = $true
$Title_Font = New-Object System.Drawing.Font("Segoe UI",$font_title,[System.Drawing.FontStyle]::Bold,[System.Drawing.GraphicsUnit]::Pixel)
$Title.Font = $Title_Font
$Form.Controls.Add($Title)
}
#--------------------------------------------------------------------
$Width = [System.Windows.Forms.Screen]::AllScreens.bounds.width
$Height = [System.Windows.Forms.Screen]::AllScreens.bounds.Height
$Height = $Height[0]
$width = $Width[0]
if($Height -le "768")
{
Smaller_768
}
elseif ($Height -gt "768" -and $Height -lt "992"){
Larger_768
}
elseif ($Height -gt "992" -and $Height -lt "1200") {
Larger_992
}
elseif ($Height -gt "1200") {
Larger_1200
}
else{
Write-Host "Cannot define the height"
}
$Form.Visible = $false
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()