CEOPrestagemk1.ps1

<#PSScriptInfo
.VERSION 1.1
.GUID bd94ad81-2c50-4050-b145-f990c3148bb3
.AUTHOR Adam Brown
.COMPANYNAME Catholic Education Diocese of Rockhampton
.COPYRIGHT
.TAGS
.LICENSEURI
.PROJECTURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES created and uploaded 08/09/2021
.DESCRIPTION Prestage application for testing and deployment
#>

 
 Param()
# Install required Modules
Write-host "Installing packages, Please wait"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$null = Install-PackageProvider -Name NuGet -Force
$null = Install-Module -Name PSWindowsUpdate –Force
$null = Install-Script -Name Get-WindowsAutoPilotInfo -force
$null = Install-Module -Name PSDiscoveryProtocol -force
$null = New-Item -Path 'c:\temp\scripts' -ItemType Directory -Force
Write-host "Package installation Complete"
Write-host "Starting Program"

# WinForm Setup
##################################################################
# Main Form .Net Objects
Add-Type -AssemblyName PresentationFramework, System.Drawing,System.ComponentModel, System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$mainForm                = New-Object System.Windows.Forms.Form
$menuMain                = New-Object System.Windows.Forms.MenuStrip
$menuFile                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuView                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuTools               = New-Object System.Windows.Forms.ToolStripMenuItem
$menuToolsA              = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOpen                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuSave                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuSaveAs              = New-Object System.Windows.Forms.ToolStripMenuItem
$menuDupdate             = New-Object System.Windows.Forms.ToolStripMenuItem
$menureboot              = New-Object System.Windows.Forms.ToolStripMenuItem
$menuSystemP             = New-Object System.Windows.Forms.ToolStripMenuItem
$menuSystemN             = New-Object System.Windows.Forms.ToolStripMenuItem
$menuSystemM             = New-Object System.Windows.Forms.ToolStripMenuItem
$menuExplorer            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuExplorerT           = New-Object System.Windows.Forms.ToolStripMenuItem
$menuTPM                 = New-Object System.Windows.Forms.ToolStripMenuItem
$menureboot              = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsR            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsN            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsW            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsS            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsM            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsRA           = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsNA           = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsWA           = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsSA           = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsMA           = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions100       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions201       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions202       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions203       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions206       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions207       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions210       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions211       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions212       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions301       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions302       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions303       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions304       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions310       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions311       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions312       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions313       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions327       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions401       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions402       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions403       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions404       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions405       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions420       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions501       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions502       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions503       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions601       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions602       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions603       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions604       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions620       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions701       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions702       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions702       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions703       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptionsWOL       = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptionsWOLA      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions100A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions201A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions202A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions203A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions206A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions207A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions210A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions211A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions212A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions301A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions302A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions303A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions304A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions310A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions311A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions312A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions313A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions327A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions401A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions402A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions403A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions404A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions405A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions420A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions501A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions502A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions503A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions601A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions602A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions603A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions604A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions620A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions701A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions702A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions702A      = New-Object System.Windows.Forms.ToolStripMenuItem
$SubmenuOptions703A      = New-Object System.Windows.Forms.ToolStripMenuItem
$menuExit                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuHelp                = New-Object System.Windows.Forms.ToolStripMenuItem
$menuHelpDiag            = New-Object System.Windows.Forms.ToolStripMenuItem
$menuHelpReport          = New-Object System.Windows.Forms.ToolStripMenuItem
$menuAbout               = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsCSV          = New-Object System.Windows.Forms.ToolStripMenuItem
$menuOptionsCSVA         = New-Object System.Windows.Forms.ToolStripMenuItem
$OutputBox               = New-Object system.Windows.Forms.TextBox

################################################################## Icons
# WinForms Icons
# Create Icon Extractor Assembly
$code = @"
using System;
using System.Drawing;
using System.Runtime.InteropServices;
 
namespace System
{
    public class IconExtractor
    {
 
     public static Icon Extract(string file, int number, bool largeIcon)
     {
      IntPtr large;
      IntPtr small;
      ExtractIconEx(file, number, out large, out small, 1);
      try
      {
       return Icon.FromHandle(largeIcon ? large : small);
      }
      catch
      {
       return null;
      }
 
     }
     [DllImport("Shell32.dll", EntryPoint = "ExtractIconExW", CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
     private static extern int ExtractIconEx(string sFile, int iIndex, out IntPtr piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
 
    }
}
"@

Add-Type -TypeDefinition $code -ReferencedAssemblies System.Drawing

# Extract PowerShell Icon from PowerShell Exe
$iconPS   = [Drawing.Icon]::ExtractAssociatedIcon((Get-Command powershell).Path)

################################################################## Main Form Setup
# Main Form
$mainForm.Height          = 640
$mainForm.Icon            = $iconPS
$mainForm.MainMenuStrip   = $menuMain
$mainForm.Width           = 840
$mainForm.StartPosition   = "CenterScreen"
$mainForm.Text            = "Prestage Assistance Tool"
$mainForm.Controls.Add($menuMain)
$mainForm.BackColor             = [System.Drawing.ColorTranslator]::FromHtml("#ffffff")

################################################################## Main Menu
# Main output box
#Output Box
$OutputBox.Name                  = 'OutputBox'
$OutputBox.Location              = '10, 220'
$OutputBox.multiline             = $true
$OutputBox.width                 = 617
$OutputBox.height                = 340
$OutputBox.ScrollBars            = 'Both'
$OutputBox.ReadOnly              = $true
$OutputBox.TabIndex              = '14'
$OutputBox.location              = New-Object System.Drawing.Point(16,235)
$OutputBox.Font                  = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$OutputBox.BackColor             = [System.Drawing.ColorTranslator]::FromHtml("#ffffff")


# Main Menu Bar
[void]$mainForm.Controls.Add($menuMain)

# Menu Options - File
$menuFile.Text = "&File"
[void]$menuMain.Items.Add($menuFile)

# Menu Options - Reboot System
$menureboot.Text         = "&Reboot"
$menureboot.Add_Click({Reboot})
[void]$menuFile.DropDownItems.Add($menureboot)

# Menu Options - File / Exit
$menuExit.ShortcutKeys = "Control, X"
$menuExit.Text         = "&Exit"
$menuExit.Add_Click({$mainForm.Close()})
[void]$menuFile.DropDownItems.Add($menuExit)

# Menu Options - Tools
$menuView.Text      = "&Tools"
[void]$menuMain.Items.Add($menuView)

# Menu Options - Download & Install Windows updates and Drivers
$menuDupdate.ShortcutKeys = "Control, F"
$menuDupdate.Text         = "&Download Updates"
$menuDupdate.Add_Click({DownloadUpdates})
[void]$menuView.DropDownItems.Add($menuDupdate)

# Menu Options - System Properties
$menuSystemP.Text         = "&System Properties"
$menuSystemP.Add_Click({Sysp})
[void]$menuView.DropDownItems.Add($menuSystemP)

# Menu Options - System Networks
$menuSystemN.Text         = "&System Networks"
$menuSystemN.Add_Click({Sysn})
[void]$menuView.DropDownItems.Add($menuSystemN)

# Menu Options - System Settings
$menuSystemM.Text         = "&System Settings"
$menuSystemM.Add_Click({Sysm})
[void]$menuView.DropDownItems.Add($menuSystemM)

# Menu Options - Explorer
$menuExplorer.Text         = "&Start Explorer"
$menuExplorer.Add_Click({Syse})
[void]$menuView.DropDownItems.Add($menuExplorer)

# Menu Options - HWID Explorer
$menuExplorerT.Text         = "&Open CSV Folder"
$menuExplorerT.Add_Click({Syst})
[void]$menuView.DropDownItems.Add($menuExplorerT)

# Menu Options - TPM
$menuTPM.Text         = "&Open TPM"
$menuTPM.Add_Click({TPM})
[void]$menuView.DropDownItems.Add($menuTPM)

# Menu Options - CSV
$menuTools.Text      = "&CSV"
[void]$menuMain.Items.Add($menuTools)

# Menu Options - Azure CSV
$menuToolsA.Text      = "&Azure CSV"
[void]$menuMain.Items.Add($menuToolsA)

# Menu Options - Rockhampton Region
$menuOptionsR.Text      = "&Rockhampton"
[void]$menuTools.DropDownItems.Add($menuOptionsR)

# Menu Options - Azure Rockhampton Region
$menuOptionsRA.Text      = "&Rockhampton"
[void]$menuToolsA.DropDownItems.Add($menuOptionsRA)

# Menu Options - Northern Region
$menuOptionsN.Text      = "&Northern"
[void]$menuTools.DropDownItems.Add($menuOptionsN)

# Menu Options - Azure Northern Region
$menuOptionsNA.Text      = "&Northern"
[void]$menuToolsA.DropDownItems.Add($menuOptionsNA)

# Menu Options - Southern Region
$menuOptionsS.Text      = "&Southern"
[void]$menuTools.DropDownItems.Add($menuOptionsS)

# Menu Options - Azure Southern Region
$menuOptionsSA.Text      = "&Southern"
[void]$menuToolsA.DropDownItems.Add($menuOptionsSA)

# Menu Options - Western Region
$menuOptionsW.Text      = "&Western"
[void]$menuTools.DropDownItems.Add($menuOptionsW)

# Menu Options - Azure Western Region
$menuOptionsWA.Text      = "&Western"
[void]$menuToolsA.DropDownItems.Add($menuOptionsWA)

# Menu Options - Misc
$menuOptionsM.Text      = "&Misc"
[void]$menuTools.DropDownItems.Add($menuOptionsM)

# Menu Options - Azure Misc
$menuOptionsMA.Text      = "&Misc"
[void]$menuToolsA.DropDownItems.Add($menuOptionsMA)

# Menu Options - Email CSV
$menuOptionsCSV.Text      = "&Email CSV"
$menuOptionsCSV.Add_Click({Email})
[void]$menuTools.DropDownItems.Add($menuOptionsCSV)

# Menu Options - Azure Email CSV
$menuOptionsCSVA.Text      = "&Email CSV"
$menuOptionsCSVA.Add_Click({Email})
[void]$menuToolsA.DropDownItems.Add($menuOptionsCSVA)

# Sub Menu Options - 100-CEO
$SubmenuOptions100.Text      = "&100-CEO"
$SubmenuOptions100.Add_Click({100CEO})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions100)

# Sub Menu Options - 201-CEO
$SubmenuOptions201.Text      = "&201-SANR"
$SubmenuOptions201.Add_Click({201SANR})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions201)

# Sub Menu Options - 202-SANR
$SubmenuOptions202.Text      = "&202-SANR"
$SubmenuOptions202.Add_Click({202SANR})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions202)

# Sub Menu Options - 203-SMNR
$SubmenuOptions203.Text      = "&203-SMNR"
$SubmenuOptions203.Add_Click({203SMNR})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions203)

# Sub Menu Options - 206-SHY
$SubmenuOptions206.Text      = "&206-SHY"
$SubmenuOptions206.Add_Click({206SHY})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions206)

# Sub Menu Options - 207-SBY
$SubmenuOptions207.Text      = "&207-SBY"
$SubmenuOptions207.Add_Click({207SBY})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions207)

# Sub Menu Options - 210-SPR
$SubmenuOptions210.Text      = "&210-SPR"
$SubmenuOptions210.Add_Click({210SPR})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions210)

# Sub Menu Options - 211-SJWL
$SubmenuOptions211.Text      = "&211-SJWL"
$SubmenuOptions211.Add_Click({211SJWL})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions211)

# Sub Menu Options - 212-SPGR
$SubmenuOptions212.Text      = "&212-SPGR"
$SubmenuOptions212.Add_Click({212SPGR})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions212)

# Sub Menu Options - 301-SJNM
$SubmenuOptions301.Text      = "&301-SJNM"
$SubmenuOptions301.Add_Click({301SJNM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions301)

# Sub Menu Options - 302-ENM
$SubmenuOptions302.Text      = "&302-ENM"
$SubmenuOptions302.Add_Click({302ENM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions302)

# Sub Menu Options - 303-MNM
$SubmenuOptions303.Text      = "&303-MNM"
$SubmenuOptions303.Add_Click({303MNM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions303)

# Sub Menu Options - 304-SBNM
$SubmenuOptions304.Text      = "&304-SBNM"
$SubmenuOptions304.Add_Click({304SBNM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions304)

# Sub Menu Options - 310-SMM
$SubmenuOptions310.Text      = "&310-SMM"
$SubmenuOptions310.Add_Click({310SMM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions310)

# Sub Menu Options - 311-SFXM
$SubmenuOptions311.Text      = "&311-SFXM"
$SubmenuOptions311.Add_Click({311SFXM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions311)

# Sub Menu Options - 312-SJWA
$SubmenuOptions312.Text      = "&312-SJWA"
$SubmenuOptions312.Add_Click({312SJWA})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions312)

# Sub Menu Options - 313-SAS
$SubmenuOptions313.Text      = "&313-SAS"
$SubmenuOptions313.Add_Click({313SAS})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions313)

# Sub Menu Options - 327-CMCM
$SubmenuOptions327.Text      = "&327-CMCM"
$SubmenuOptions327.Add_Click({327CMCM})
[void]$menuOptionsN.DropDownItems.Add($SubmenuOptions327)

# Sub Menu Options - 401-SOSG
$SubmenuOptions401.Text      = "&401-SOSG"
$SubmenuOptions401.Add_Click({401SOSG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions401)

# Sub Menu Options - 402-SJG
$SubmenuOptions402.Text      = "&402-SJG"
$SubmenuOptions402.Add_Click({402SJG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions402)

# Sub Menu Options - 403-SJBI
$SubmenuOptions403.Text      = "&403-SJBI"
$SubmenuOptions403.Add_Click({403SJBI})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions403)

# Sub Menu Options - 404-STM
$SubmenuOptions404.Text      = "&404-STM"
$SubmenuOptions404.Add_Click({404STM})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions404)

# Sub Menu Options - 405-SFTS
$SubmenuOptions405.Text      = "&405-SFTS"
$SubmenuOptions405.Add_Click({405SFTS})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions405)

# Sub Menu Options - 420-CCG
$SubmenuOptions420.Text      = "&420-CCG"
$SubmenuOptions420.Add_Click({420CCG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions420)

# Sub Menu Options - 501-SJBG
$SubmenuOptions501.Text      = "&501-SJBG"
$SubmenuOptions501.Add_Click({501SJBG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions501)

# Sub Menu Options - 502-SPBG
$SubmenuOptions502.Text      = "&502-SPBG"
$SubmenuOptions502.Add_Click({502SPBG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions502)

# Sub Menu Options - 503-SMBG
$SubmenuOptions503.Text      = "&503-SMBG"
$SubmenuOptions503.Add_Click({503SMBG})
[void]$menuOptionsS.DropDownItems.Add($SubmenuOptions503)

# Sub Menu Options - 601-SPE
$SubmenuOptions601.Text      = "&601-SPE"
$SubmenuOptions601.Add_Click({601SPE})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions601)

# Sub Menu Options - 602-SJC
$SubmenuOptions602.Text      = "&602-SJC"
$SubmenuOptions602.Add_Click({602SJC})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions602)

# Sub Menu Options - 603-OLSHS
$SubmenuOptions603.Text      = "&603-OLSHS"
$SubmenuOptions603.Add_Click({603OLSHS})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions603)

# Sub Menu Options - 604-SBE
$SubmenuOptions604.Text      = "&604-SBE"
$SubmenuOptions604.Add_Click({604SBE})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions604)

# Sub Menu Options - 620-MCE
$SubmenuOptions620.Text      = "&620-MCE"
$SubmenuOptions620.Add_Click({620MCE})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions620)

# Sub Menu Options - 701-OLL
$SubmenuOptions701.Text      = "&701-OLL"
$SubmenuOptions701.Add_Click({701OLL})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions701)

# Sub Menu Options - 702-SJBA
$SubmenuOptions702.Text      = "&702-SJBA"
$SubmenuOptions702.Add_Click({702SJBA})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions702)

# Sub Menu Options - 703-SJBL
$SubmenuOptions703.Text      = "&703-SJBL"
$SubmenuOptions703.Add_Click({703SJBL})
[void]$menuOptionsW.DropDownItems.Add($SubmenuOptions703)

# Sub Menu Options - WOL
$SubmenuOptionsWOL.Text      = "&WOL"
$SubmenuOptionsWOL.Add_Click({WOL})
[void]$menuOptionsM.DropDownItems.Add($SubmenuOptionsWOL)

# Sub Menu Options - Azure 100-CEO
$SubmenuOptions100A.Text      = "&100-CEO"
$SubmenuOptions100A.Add_Click({100CEOA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions100A)

# Sub Menu Options - Azure 201-CEO
$SubmenuOptions201A.Text      = "&201-SANR"
$SubmenuOptions201A.Add_Click({201SANRA})
[void]$menuOptionsR.DropDownItems.Add($SubmenuOptions201A)

# Sub Menu Options - Azure 202-SANR
$SubmenuOptions202A.Text      = "&202-SANR"
$SubmenuOptions202A.Add_Click({202SANRA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions202A)

# Sub Menu Options - Azure 203-SMNR
$SubmenuOptions203A.Text      = "&203-SMNR"
$SubmenuOptions203A.Add_Click({203SMNRA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions203A)

# Sub Menu Options - Azure 206-SHY
$SubmenuOptions206A.Text      = "&206-SHY"
$SubmenuOptions206A.Add_Click({206SHYA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions206A)

# Sub Menu Options - Azure 207-SBY
$SubmenuOptions207A.Text      = "&207-SBY"
$SubmenuOptions207A.Add_Click({207SBYA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions207A)

# Sub Menu Options - Azure 210-SPR
$SubmenuOptions210A.Text      = "&210-SPR"
$SubmenuOptions210A.Add_Click({210SPRA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions210A)

# Sub Menu Options - Azure 211-SJWL
$SubmenuOptions211A.Text      = "&211-SJWL"
$SubmenuOptions211A.Add_Click({211SJWLA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions211A)

# Sub Menu Options - Azure 212-SPGR
$SubmenuOptions212A.Text      = "&212-SPGR"
$SubmenuOptions212A.Add_Click({212SPGRA})
[void]$menuOptionsRA.DropDownItems.Add($SubmenuOptions212A)

# Sub Menu Options - Azure 301-SJNM
$SubmenuOptions301A.Text      = "&301-SJNM"
$SubmenuOptions301A.Add_Click({301SJNMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions301A)

# Sub Menu Options - Azure 302-ENM
$SubmenuOptions302A.Text      = "&302-ENM"
$SubmenuOptions302A.Add_Click({302ENMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions302A)

# Sub Menu Options - Azure 303-MNM
$SubmenuOptions303A.Text      = "&303-MNM"
$SubmenuOptions303A.Add_Click({303MNMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions303A)

# Sub Menu Options - Azure 304-SBNM
$SubmenuOptions304A.Text      = "&304-SBNM"
$SubmenuOptions304A.Add_Click({304SBNMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions304A)

# Sub Menu Options - Azure 310-SMM
$SubmenuOptions310A.Text      = "&310-SMM"
$SubmenuOptions310A.Add_Click({310SMMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions310A)

# Sub Menu Options - Azure 311-SFXM
$SubmenuOptions311A.Text      = "&311-SFXM"
$SubmenuOptions311A.Add_Click({311SFXMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions311A)

# Sub Menu Options - Azure 312-SJWA
$SubmenuOptions312A.Text      = "&312-SJWA"
$SubmenuOptions312A.Add_Click({312SJWAA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions312A)

# Sub Menu Options - Azure 313-SAS
$SubmenuOptions313A.Text      = "&313-SAS"
$SubmenuOptions313A.Add_Click({313SASA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions313A)

# Sub Menu Options - Azure 327-CMCM
$SubmenuOptions327A.Text      = "&327-CMCM"
$SubmenuOptions327A.Add_Click({327CMCMA})
[void]$menuOptionsNA.DropDownItems.Add($SubmenuOptions327A)

# Sub Menu Options - Azure 401-SOSG
$SubmenuOptions401A.Text      = "&401-SOSG"
$SubmenuOptions401A.Add_Click({401SOSGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions401A)

# Sub Menu Options - Azure 402-SJG
$SubmenuOptions402A.Text      = "&402-SJG"
$SubmenuOptions402A.Add_Click({402SJGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions402A)

# Sub Menu Options - Azure 403-SJBI
$SubmenuOptions403A.Text      = "&403-SJBI"
$SubmenuOptions403A.Add_Click({403SJBIA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions403A)

# Sub Menu Options - Azure 404-STM
$SubmenuOptions404A.Text      = "&404-STM"
$SubmenuOptions404A.Add_Click({404STMA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions404A)

# Sub Menu Options - Azure 405-SFTS
$SubmenuOptions405A.Text      = "&405-SFTS"
$SubmenuOptions405A.Add_Click({405SFTSA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions405A)

# Sub Menu Options - Azure 420-CCG
$SubmenuOptions420A.Text      = "&420-CCG"
$SubmenuOptions420A.Add_Click({420CCGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions420A)

# Sub Menu Options - Azure 501-SJBG
$SubmenuOptions501A.Text      = "&501-SJBG"
$SubmenuOptions501A.Add_Click({501SJBGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions501A)

# Sub Menu Options - Azure 502-SPBG
$SubmenuOptions502A.Text      = "&502-SPBG"
$SubmenuOptions502A.Add_Click({502SPBGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions502A)

# Sub Menu Options - Azure 503-SMBG
$SubmenuOptions503A.Text      = "&503-SMBG"
$SubmenuOptions503A.Add_Click({503SMBGA})
[void]$menuOptionsSA.DropDownItems.Add($SubmenuOptions503A)

# Sub Menu Options - Azure 601-SPE
$SubmenuOptions601A.Text      = "&601-SPE"
$SubmenuOptions601A.Add_Click({601SPEA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions601A)

# Sub Menu Options - Azure 602-SJC
$SubmenuOptions602A.Text      = "&602-SJC"
$SubmenuOptions602A.Add_Click({602SJCA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions602A)

# Sub Menu Options - Azure 603-OLSHS
$SubmenuOptions603A.Text      = "&603-OLSHS"
$SubmenuOptions603A.Add_Click({603OLSHSA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions603A)

# Sub Menu Options - Azure 604-SBE
$SubmenuOptions604A.Text      = "&604-SBE"
$SubmenuOptions604A.Add_Click({604SBEA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions604A)

# Sub Menu Options - Azure 620-MCE
$SubmenuOptions620A.Text      = "&620-MCE"
$SubmenuOptions620A.Add_Click({620MCEA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions620A)

# Sub Menu Options - Azure 701-OLL
$SubmenuOptions701A.Text      = "&701-OLL"
$SubmenuOptions701A.Add_Click({701OLLA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions701A)

# Sub Menu Options - Azure 702-SJBA
$SubmenuOptions702A.Text      = "&702-SJBA"
$SubmenuOptions702A.Add_Click({702SJBAA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions702A)

# Sub Menu Options - Azure 703-SJBL
$SubmenuOptions703A.Text      = "&703-SJBL"
$SubmenuOptions703A.Add_Click({703SJBLA})
[void]$menuOptionsWA.DropDownItems.Add($SubmenuOptions703A)

# Sub Menu Options - Azure WOL
$SubmenuOptionsWOLA.Text      = "&WOL"
$SubmenuOptionsWOLA.Add_Click({WOLA})
[void]$menuOptionsMA.DropDownItems.Add($SubmenuOptionsWOLA)

# Menu Options - Help
$menuHelp.Text      = "&Help"
[void]$menuMain.Items.Add($menuHelp)


# Menu Options - Diag
$menuHelpDiag.Image     = [System.Drawing.SystemIcons]::Information
$menuHelpDiag.Text      = "Run MDM Diagnostics"
$menuHelpDiag.Add_Click({Diag})
[void]$menuHelp.DropDownItems.Add($menuHelpDiag)

# Menu Options - Report
$menuHelpReport.Image     = [System.Drawing.SystemIcons]::Information
$menuHelpReport.Text      = "Run Systems report"
$menuHelpReport.Add_Click({Report})
[void]$menuHelp.DropDownItems.Add($menuHelpReport)

# Menu Options - Help / About
$menuAbout.Image     = [System.Drawing.SystemIcons]::Information
$menuAbout.Text      = "About Prestage Asstaince Tool"
$menuAbout.Add_Click({About})
[void]$menuHelp.DropDownItems.Add($menuAbout)

################################################################## Functions
function OpenFile {
    $statusLabel.Text = "Open File"
    $selectOpenForm = New-Object System.Windows.Forms.OpenFileDialog
    $selectOpenForm.Filter = "All Files (*.*)|*.*"
    $selectOpenForm.InitialDirectory = ".\"
    $selectOpenForm.Title = "Select a File to Open"
    $getKey = $selectOpenForm.ShowDialog()
    If ($getKey -eq "OK") {
            $inputFileName = $selectOpenForm.FileName
    }
    $statusLabel.Text = "Ready"
}

function SaveAs {
    $statusLabel.Text = "Save As"
    $selectSaveAsForm = New-Object System.Windows.Forms.SaveFileDialog
    $selectSaveAsForm.Filter = "All Files (*.*)|*.*"
    $selectSaveAsForm.InitialDirectory = ".\"
    $selectSaveAsForm.Title = "Select a File to Save"
    $getKey = $selectSaveAsForm.ShowDialog()
    If ($getKey -eq "OK") {
            $outputFileName = $selectSaveAsForm.FileName
    }
    $statusLabel.Text = "Ready"
}

function SaveFile {
}

function DownloadUpdates{
             $o = Write-host "Begining background download of Drivers and Windows updates"
             $OutputBox.Text =  $o | Out-String
             Install-WindowsUpdate -AcceptAll -Install -IgnoreReboot | Out-File "c:\temp\scripts\$(get-date -f yyyy-MM-dd)-WindowsUpdate.log" -force
                        }
function Sysp{
             sysdm.cpl
               }
function TPM{
             TPM
               }

function Sysn{
             start ms-availablenetworks:
               }

function Sysm{
             start ms-settings:
               }

function Syse{
             Invoke-Item c:\
               }
function Syst{
             Invoke-Item c:\HWID\
               }

function Email{
               $user = wmic bios get serialnumber
               Set-Location c:\\HWID
               $site = Get-Content C:\hwid\Site.txt
               Send-MailMessage -from "itSupport@rok.catholic.edu.au" -to "Help@rok.catholic.edu.au" -subject "$Site CSV Import Required" -bodyashtml "Please assist importing the following $user " -Attachments "$serial.csv" -smtpserver "mail.rok.catholic.edu.au"
               }

function 100CEO {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "100"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 100-CEO
}
function 201SANR {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "201"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 201-SANR
}
function 202SANR {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "202"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 202-SJPA 
}
function 203SMNR {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "203"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 203-SMNR 
}
function 206SHY {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "206"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 206-SHY
}
function 207SBY {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "207"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 207-SBY 
}
function 210SPR {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "210"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 210-SPR
}
function 211SJWL {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "211"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 211-SJWL
}
function 212SPGR {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "212"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 212-SPGR
}
function 301SJNM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "301"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 301-SJNM
}
function 302ENM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "302"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 302-ENM
}
function 303MNM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "303"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 303-MNM 
}
function 304SBNM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "304"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 304-SBNM
}
function 310SMM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "310"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 310-SMM
}
function 311SFXM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "311"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 311-SFXM
}
function 312SJWA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "312"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 312-SJWA
}
function 313SAS {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "313"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 313-SAS
}
function 327CMCM {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "327"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 327A-CMCM
}
function 401SOSG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "401"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 401-SOSG
}
function 402SJG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "402"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 402-SJG
}
function 403SJBI {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "403"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 403-SJBI
}
function 404STM  {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "404"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 404-STM
}
function 405SFTS  {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "405"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 405-SFTS
}
function 420CCG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "420"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 420-CCG
}
function 501SJBG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "501"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 501-SJBG 
}
function 502SPBG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "502"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 502-SPBG
}
function 503SMBG {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "503"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 503-SMBG
}
function 601SPE {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "601"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 601-SPE 
}
function 602SJC {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "602"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 602-SJC
}
function 603OLSHS {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "603"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 603-OLSHS
}
function 604SBE {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "604"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 604-SBE
}
function 620MCE {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "620"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 620-MCE
}
function 701OLL {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "701"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 701-OLL
}
function 702SJBA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "702"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 702-SJBA
}
function 703SJBL {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "703"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 703-SJBL
}
function 100CEOA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "100"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 100A-CEO
}
function 201SANRA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "201"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 201A-SANR
}
function 202SANRA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "202"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 202A-SJPA 
}
function 203SMNRA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "203"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 203A-SMNR 
}
function 206SHYA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "206"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 206A-SHY
}
function 207SBYA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "207"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 207A-SBY 
}
function 210SPRA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "210"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 210A-SPR
}
function 211SJWLA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "211"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 211A-SJWL
}
function 212SPGRA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "212"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 212A-SPGR
}
function 301SJNMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "301"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 301A-SJNM
}
function 302ENMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "302"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 302A-ENM
}
function 303MNMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "303"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 303A-MNM 
}
function 304SBNMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "304"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 304A-SBNM
}
function 310SMMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "310"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 310A-SMM
}
function 311SFXMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "311"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 311A-SFXM
}
function 312SJWAA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "312"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 312A-SJWA
}
function 313SASA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "313"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 313A-SAS
}
function 327CMCMA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "327"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 327A-CMCM
}
function 401SOSGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "401"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 401A-SOSG
}
function 402SJGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "402"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 402A-SJG
}
function 403SJBIA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "403"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 403A-SJBI
}
function 404STMA  {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "404"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 404A-STM
}
function 405SFTSA  {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "405"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 405A-SFTS
}
function 420CCGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "420"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 420A-CCG
}
function 501SJBGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "501"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 501A-SJBG 
}
function 502SPBGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "502"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 502A-SPBG
}
function 503SMBGA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "503"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 503A-SMBG
}
function 601SPEA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "601"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 601A-SPE 
}
function 602SJCA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "602"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 602A-SJC
}
function 603OLSHSA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "603"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 603A-OLSHS
}
function 604SBEA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "604"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 604A-SBE
}
function 620MCEA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "620"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 620A-MCE
}
function 701OLLA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "701"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 701A-OLL
}
function 702SJBAA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "702"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 702A-SJBA
}
function 703SJBLA {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "703"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag 703A-SJBL

}
function WOL {
                md c:\\HWID -Force
                Set-Location c:\\HWID
                Remove-Item c:\HWID\* -Recurse -Force
                New-Item "C:\hwid\Site.txt" -ItemType File -Value "100"
                $serial = (gwmi win32_bios).SerialNumber
                Get-WindowsAutoPilotInfo.ps1 -OutputFile "$serial.csv" -Append -GroupTag WOL
}
function Diag {
                $FileName = "c:\temp\Autopilot.cab"
                if (Test-Path $FileName) {
                Remove-Item $FileName
                }
                MDMDiagnosticsTool.exe -area Autopilot -cab c:\temp\Autopilot.cab
                ii c:\temp\
                }
function Report {
#CSS codes
$header = @"
<style>
    h1 {
        font-family: Arial, Helvetica, sans-serif;
        color: #e68a00;
        font-size: 28px;
    }
    h2 {
        font-family: Arial, Helvetica, sans-serif;
        color: #000099;
        font-size: 16px;
    }
    table {
        font-size: 12px;
        border: 0px;
        font-family: Arial, Helvetica, sans-serif;
    }
    td {
        padding: 4px;
        margin: 0px;
        border: 0;
    }
    th {
        background: #395870;
        background: linear-gradient(#49708f, #293f50);
        color: #fff;
        font-size: 11px;
        text-transform: uppercase;
        padding: 10px 15px;
        vertical-align: middle;
    }
    tbody tr:nth-child(even) {
        background: #f0f0f2;
    }
    #CreationDate {
        font-family: Arial, Helvetica, sans-serif;
        color: #ff3300;
        font-size: 12px;
    }
    .StopStatus {
        color: #ff0000;
    }
    .RunningStatus {
        color: #008000;
    }
</style>
"@

#The command below will get the name of the computer
$ComputerName = "<h1>Computer name: $env:computername</h1>"
#The command below will get the Operating System information, convert the result to HTML code as table and store it to a variable
$OSinfo = Get-CimInstance -Class Win32_OperatingSystem | ConvertTo-Html -As List -Property Version,Caption,BuildNumber,Manufacturer -Fragment -PreContent "<h2>Operating System Information</h2>"
#The command below will get the Processor information, convert the result to HTML code as table and store it to a variable
$ProcessInfo = Get-CimInstance -ClassName Win32_Processor | ConvertTo-Html -As List -Property DeviceID,Name,Caption,MaxClockSpeed,SocketDesignation,Manufacturer -Fragment -PreContent "<h2>Processor Information</h2>"
#The command below will get the BIOS information, convert the result to HTML code as table and store it to a variable
$BiosInfo = Get-CimInstance -ClassName Win32_BIOS | ConvertTo-Html -As List -Property SMBIOSBIOSVersion,Manufacturer,Name,SerialNumber -Fragment -PreContent "<h2>BIOS Information</h2>"
#The command below will get the details of Disk, convert the result to HTML code as table and store it to a variable
$DiscInfo = Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType=3" | ConvertTo-Html -As List -Property DeviceID,DriveType,ProviderName,VolumeName,Size,FreeSpace -Fragment -PreContent "<h2>Disk Information</h2>"
#The command below will get the details of Disk, convert the result to HTML code as table and store it to a variable
$TPMInfo = Get-TPM | ConvertTo-Html -As List -Property TpmPresent,TpmReady,ManufacturerIdTxt,ManufacturerVersion,ManufacturerVersionFull20,OwnerAuth -Fragment -PreContent "<h2>TPM Information</h2>"
#The command below will combine all the information gathered into a single HTML report
$Report = ConvertTo-HTML -Body "$ComputerName $OSinfo $ProcessInfo $BiosInfo $TPMInfo $DiscInfo " -Head $header -Title "Computer Information Report" -PostContent "<p id='CreationDate'>Creation Date: $(Get-Date)</p>"
#The command below will generate the report to an HTML file
$serial = (gwmi win32_bios).SerialNumber
md c:\\temp -Force
Set-Location c:\\temp
$Report | Out-File .\"$serial.Html"
ii c:\temp\$serial.Html
}

function About {
    #$statusLabel.Text = "About"
    # About Form Objects
    $aboutForm          = New-Object System.Windows.Forms.Form
    $aboutFormExit      = New-Object System.Windows.Forms.Button
    $aboutFormImage     = New-Object System.Windows.Forms.PictureBox
    $aboutFormNameLabel = New-Object System.Windows.Forms.Label
    $aboutFormText      = New-Object System.Windows.Forms.Label

    # About Form
    $aboutForm.AcceptButton  = $aboutFormExit
    $aboutForm.CancelButton  = $aboutFormExit
    $aboutForm.ClientSize    = "350, 140"
    $aboutForm.ControlBox    = $false
    $aboutForm.ShowInTaskBar = $false
    $aboutForm.StartPosition = "CenterParent"
    $aboutForm.Text          = "About Prestage Asstaince Tool"
    $aboutForm.Add_Load($aboutForm_Load)

    # About PictureBox
    $aboutFormImage.Image    = $iconPS.ToBitmap()
    $aboutFormImage.Location = "55, 15"
    $aboutFormImage.Size     = "32, 32"
    $aboutFormImage.SizeMode = "StretchImage"
    $aboutForm.Controls.Add($aboutFormImage)

    # About Name Label
    $aboutFormNameLabel.Font     = New-Object Drawing.Font("Microsoft Sans Serif", 9, [System.Drawing.FontStyle]::Bold)
    $aboutFormNameLabel.Location = "110, 10"
    $aboutFormNameLabel.Size     = "200, 30"
    $aboutFormNameLabel.Text     = "Prestage Asstaince Tool `n`r v0.1"
    $aboutForm.Controls.Add($aboutFormNameLabel)

    # About Text Label
    $aboutFormText.Location = "100, 60"
    $aboutFormText.Size     = "300, 40"
    $aboutFormText.Text     = " Created by Adam Brown `n`r (╯°□°)╯︵ ┻━┻ "
    $aboutForm.Controls.Add($aboutFormText)

    # About Exit Button
    $aboutFormExit.Location = "135, 100"
    $aboutFormExit.Text     = "OK"
    $aboutForm.Controls.Add($aboutFormExit)

    [void]$aboutForm.ShowDialog()
    #$statusLabel.Text = "Ready"
} # End About

#PreStage Check
$Prestage                         = New-Object system.Windows.Forms.Button
$Prestage.text                    = "Run Prestage"
$Prestage.width                   = 120
$Prestage.height                  = 30
$Prestage.location                = New-Object System.Drawing.Point(11,40)
$Prestage.ForeColor               = [Drawing.Color]::White
$Prestage.Font                    = New-Object System.Drawing.Font('Microsoft Sans Serif',9,[System.Drawing.FontStyle]([System.Drawing.FontStyle]::Regular))
$Prestage.BackColor               = [System.Drawing.ColorTranslator]::FromHtml("#008AD7")
$Prestage.Add_Click({
Write-Host "#####################################################" -ForegroundColor White 
Write-Host "Downloading & Installing packages" -ForegroundColor Green 
$null = Install-PackageProvider -Name NuGet -Force
Write-Host "Processing requests" -ForegroundColor Cyan 
$null = Install-Module -Name PSWindowsUpdate –Force
Write-Host "Begining Folder Creation Process" -ForegroundColor Green 
$null = New-Item -Path 'c:\temp\scripts' -ItemType Directory -Force
Write-Host "Process Completed" -ForegroundColor Cyan 
Write-Host "Begining System Update Process" -ForegroundColor Green 
$null = $Updates = Get-WUList
Write-Host "Updates Found: " $Updates.Count
$null = Install-WindowsUpdate -AcceptAll -Install -IgnoreReboot | Out-File "c:\temp\scripts\$(get-date -f yyyy-MM-dd)-WindowsUpdate.log" -force
Write-Host "Logs Created c:\temp\scripts" -ForegroundColor Cyan
Write-Host "System ready to Provision" -ForegroundColor Cyan 
$Time = 11
    for ($Timer = $Time; $Timer -gt 0; $Timer--) {
      Write-Host "`Reboot in $Timer" -ForegroundColor Red
      Start-Sleep -Milliseconds 1000
  }
Shutdown -t 0 -r 
})

#Network Button
$Networkcheck                    = New-Object system.Windows.Forms.Button
$Networkcheck.text               = "Network Check"
$Networkcheck.width              = 120
$Networkcheck.height             = 30
$Networkcheck.location           = New-Object System.Drawing.Point(11,80)
$Networkcheck.ForeColor          = [Drawing.Color]::White
$Networkcheck.Font               = New-Object System.Drawing.Font('Microsoft Sans Serif',9,[System.Drawing.FontStyle]([System.Drawing.FontStyle]::Regular))
$Networkcheck.BackColor          = [System.Drawing.ColorTranslator]::FromHtml("#008AD7")
$Networkcheck.Add_Click({
    $o = Invoke-DiscoveryProtocolCapture -Type LLDP -force | Get-DiscoveryProtocolData
    $OutputBox.Text =  $o | Out-String
})

#Hardware Button
$HDcheck                         = New-Object system.Windows.Forms.Button
$HDcheck.text                    = "List Hardware"
$HDcheck.width                   = 120
$HDcheck.height                  = 30
$HDcheck.location                = New-Object System.Drawing.Point(11,120)
$HDcheck.ForeColor               = [Drawing.Color]::White
$HDcheck.Font                    = New-Object System.Drawing.Font('Microsoft Sans Serif',9,[System.Drawing.FontStyle]([System.Drawing.FontStyle]::Regular))
$HDcheck.BackColor               = [System.Drawing.ColorTranslator]::FromHtml("#008AD7")
$HDcheck.Add_Click({
    #$iD = "userid"
    $OutputBox.Text =  $System,$Serial,$monitor | Out-String
    })

# Show Main Form
$mainForm.controls.AddRange(@($Prestage,$Networkcheck,$OutputBox,$HDcheck,$label2,$label3,$label4,$label5,$label6 ))

#Queries
$monitor = Get-CimInstance -Namespace root\wmi -ClassName wmimonitorid | foreach {
           New-Object -TypeName psobject -Property @{
           Manufacturer = ($_.ManufacturerName -notmatch '^0$' | foreach {[char]$_}) -join ""
           Name = ($_.UserFriendlyName -notmatch '^0$' | foreach {[char]$_}) -join ""
           Serial = ($_.SerialNumberID -notmatch '^0$' | foreach {[char]$_}) -join ""
            }
            }

$System = (Get-CimInstance Win32_Computersystem).Model
$Serial = (get-wmiobject win32_bios).serialnumber
$Bios = (get-wmiobject win32_bios).SMBIOSBIOSVersion
$Windows = "Version $($Version.DisplayVersion) (OS Build $($Version.CurrentBuildNumber).$($Version.UBR))"
$Updates = Get-WUList
$Version = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\').DisplayVersion
$user = $env:username
$computer= $env:COMPUTERNAME
$OSBuild = (Get-CimInstance -ClassName CIM_OperatingSystem).Version

# label2 End User and set text and location
$label2 = New-Object System.Windows.Forms.Label
$Label2.Text = "Winver: $Version"
$Label2.BackColor = "Transparent"
$Label2.AutoSize = $True
$label2.Location = New-Object Drawing.Point (200,50)
$mainForm.Controls.Add($Label2)

# label3 Hostname and set text and location
$label3 = New-Object System.Windows.Forms.Label
$Label3.Text = "Serial: $Serial"
$Label3.BackColor = "Transparent"
$Label3.AutoSize = $True
$label3.Location = New-Object Drawing.Point (200,70)
$mainForm.Controls.Add($Label3)

# label4 IP Address and set text and location
$label4 = New-Object System.Windows.Forms.Label
$Label4.Text = "Model: $System"
$label4.BackColor = "Transparent"
$Label4.AutoSize = $True
$label4.Location = New-Object Drawing.Point (200,90)
$mainForm.Controls.Add($Label4)

# label5 End User and set text and location
$label5 = New-Object System.Windows.Forms.Label
$Label5.Text = "Winbuild: $OSBuild"
$Label5.BackColor = "Transparent"
$Label5.AutoSize = $True
$label5.Location = New-Object Drawing.Point (200,110)
$mainForm.Controls.Add($Label5)

# label6 End User and set text and location
$label6 = New-Object System.Windows.Forms.Label
$Label6.Text = "Bios Ver: $Bios"
$Label6.BackColor = "Transparent"
$Label6.AutoSize = $True
$label6.Location = New-Object Drawing.Point (200,130)
$mainForm.Controls.Add($Label6)

[void] $mainForm.ShowDialog()