####################################
# Base System Changes and UI Tweaks
####################################

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Confirm:$False -force
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -confirm:$false
$PSRepository = get-PSRepository
if ($PSRepository.installationpolicy -ne 'Trusted') {
    Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
}

$32apps = Get-WmiObject -class win32_product
$32bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
$64bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
$apps = $32bit + $64bit

#Disable Windows 10 Fast startup
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name HiberbootEnabled -Value 0 
#Set Power Plan to High Performance
powercfg.exe -SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3
powercfg -change -standby-timeout-ac 0
powercfg -change -hibernate-timeout-ac 0

#Enable Unzip Function
Add-Type -AssemblyName System.IO.Compression.FileSystem
function unzip {
	param( [string]$ziparchive, [string]$extractpath )
	[System.IO.Compression.ZipFile]::ExtractToDirectory( $ziparchive, $extractpath )
}

#Create Support Directories
New-Item -ItemType directory -Path C:\support -ErrorAction SilentlyContinue
New-Item -ItemType directory -Path C:\support\software -ErrorAction SilentlyContinue
New-Item -ItemType directory -Path C:\support\software\AnyDesk -ErrorAction SilentlyContinue

#Install Boab Syncro Agent
write-host 'Installing Syncro agent..' -ForegroundColor Yellow
if($apps.DisplayName -ne 'Syncro'){
	Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SyncroSetup-boab_it_provisioning-v1-2707067.exe' -Method 'GET' -OutFile "c:\support\software\SyncroSetup-boab_it_provisioning-v1-2707067.exe"
	start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SyncroSetup-boab_it_provisioning-v1-2707067.exe' 
	Start-sleep 60
	$syncro = get-process | where-object { $_.ProcessName -eq "SyncroSetup-boab_it_provisioning-v1-2707067" }
	if ($null -ne $syncro) {
		taskkill /pid $($Syncro.id) /f
	}
	$syncro = get-process | where-object { $_.ProcessName -eq "Syncro.Installer" }
	if ($null -ne $syncro) {
		taskkill /pid $($Syncro.id) /f
	}	
}

#Start WinRM Service
Start-Service WinRM -verbose

#Enable System restore 
Enable-ComputerRestore -Drive "C:\" -confirm:$false

#Check and Create admin account
$user = get-localuser | Where-Object { $_.name -eq "administrator" }
$pass = 'boab123' | ConvertTo-SecureString -AsPlainText -Force
if ($user.enabled -eq $true) {
	set-localuser -name $user -password $pass
	Add-LocalGroupMember -group 'administrators' -Member $user -ErrorAction SilentlyContinue
	Write-host 'Password has been successfully set'
} elseif ($user.enabled -eq $false) {
	Enable-LocalUser -name 'administrator'
	Set-LocalUser -name 'administrator' -password $pass
	Write-host 'Administrator Account has been successfully Enabled'
}

# Create Hidden BITS Accounts
#net user BITS x1jT0kh83v /add 
#net localgroup Administrators BITS /add
#reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\Userlist" /v BITS /t REG_DWORD /d 0 /f

#Enable SMB and ICMP on Windows Firewall
Write-host 'Enable SMB and ICMP on Windows Firewall' -ForegroundColor yellow
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-In)" -Enabled True
Set-NetFirewallRule -DisplayName "File and Printer Sharing (Echo Request - ICMPv4-Out)" -Enabled True
Set-NetFirewallRule -DisplayName "File and Printer Sharing (SMB-In)" -Enabled True
Set-NetFirewallRule -DisplayName "File and Printer Sharing (SMB-Out)" -Enabled True


# Set WinUserLanguageList as a variable
$lang = Get-WinUserLanguageList 
# Clear the WinUserLanguageList
$lang.Clear()
# Add language to the language list
$lang.add("en-AU")
# Remove whatever input method is present
$lang[0].InputMethodTips.Clear()
# Add this keyboard as keyboard language
$lang[0].InputMethodTips.Add('0C09:00000409')
# Set this language list as default
Set-WinUserLanguageList $lang -Force
# Make region settings independent of OS language
Set-WinCultureFromLanguageListOptOut -OptOut $True
# Set Windows Dispaly Language
Set-WinUILanguageOverride -Language en-AU
# Set region to this Country
Set-Culture en-AU
# Set the location to this location
Set-WinHomeLocation -GeoId 12
# Set non-unicode legacy software to use this language as default
Set-WinSystemLocale -SystemLocale en-AU
# Set the TimeZone
Set-TimeZone -name 'AUS Eastern Standard Time'
#Brisbane Standard Time
# E. Australia Standard Time
#Darwin Standard Time
# AUS Central Standard Time
#Adelaide Standard Time
# Cen. Australia Standard Time

#Fix Network Print
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Print" -name "RpcAuthnLevelPrivacyEnabled" -value 00000000 -type dword

# Default preset
$tweaks = @(
	### Require administrator privileges ###
	"RequireAdmin",
	"EnableRemoteDesktop",
	"DisableSleepTimeout",
	"HideTaskbarPeopleIcon",
	"EnableNumlock"
)

# Relaunch the script with administrator privileges
Function RequireAdmin {
	If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
		Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -WorkingDirectory $pwd -Verb RunAs
		Exit
	}
}
# Enable Remote Desktop w/o Network Level Authentication
Function EnableRemoteDesktop {
	Write-Output "Enabling Remote Desktop w/o Network Level Authentication..."
	Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 0
	Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Type DWord -Value 0
	Enable-NetFirewallRule -Name "RemoteDesktop*"
}
# Disable display and sleep mode timeouts
Function DisableSleepTimeout {
	Write-Output "Disabling sleep mode timeouts for AC..."
	powercfg /X standby-timeout-ac 0
	powercfg -change hibernate-timeout-ac 0
}
# Hide Taskbar People icon
Function HideTaskbarPeopleIcon {
	Write-Output "Hiding People icon..."
	If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) {
		New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" | Out-Null
	}
	Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 0
}

# Enable NumLock after startup
Function EnableNumlock {
	Write-Output "Enabling NumLock after startup..."
	If (!(Test-Path "HKU:")) {
		New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null
	}
	Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2147483650
	Add-Type -AssemblyName System.Windows.Forms
	If (!([System.Windows.Forms.Control]::IsKeyLocked('NumLock'))) {
		$wsh = New-Object -ComObject WScript.Shell
		$wsh.SendKeys('{NUMLOCK}')
	}
}
# Normalize path to preset file
$preset = ""
$PSCommandArgs = $args
If ($args -And $args[0].ToLower() -eq "-preset") {
	$preset = Resolve-Path $($args | Select-Object -Skip 1)
	$PSCommandArgs = "-preset `"$preset`""
}
# Load function names from command line arguments or a preset file
If ($args) {
	$tweaks = $args
	If ($preset) {
		$tweaks = Get-Content $preset -ErrorAction Stop | ForEach { $_.Trim() } | Where { $_ -ne "" -and $_[0] -ne "#" }
	}
}

# Call the desired tweak functions
$tweaks | ForEach { Invoke-Expression $_ }

##################
# .Net Framework 3.5
##################
Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3"

####################################################
# Install Office 2016 - Office 365 Business Premium
####################################################
$office = $apps | where-object {$_.displayname -like "*Office 16 Click-to-Run*"}
if($null -eq $office){
	Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/O365_BP_x64.zip' -Method 'GET' -OutFile "c:\support\software\O365_BP_x64.zip"
	unzip "c:\support\software\O365_BP_x64.zip" "c:\support\software\office"
	C:\support\software\office\setup.exe /configure 'C:\support\software\office\configuration.xml'
}


##################
# Google Chrome
##################
$Chrome = $apps | where-object {$_.displayname -like "*chrome*"}
if($null -eq $Chrome){
$Path = 'C:\support\Software'
$Installer = "chrome_installer.exe" 
Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer
Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait
}

##################
# Anydesk
##################
$anydesk = $apps | where-object {$_.displaynamename -like "*anydesk*"}
if($null -eq $anydesk){
write-host 'Installing Anydesk' -ForegroundColor yellow
invoke-webrequest -uri "https://boabcdn.blob.core.windows.net/cdn/BoabITAnyDesk.msi" -OutFile "C:\Support\Software\AnyDesk\BoabITAnyDesk.msi"
set-location "C:\support\software\AnyDesk\"
.\BoabITAnyDesk.msi /quiet
}

##################
# Install VLC
##################
$vlc = $apps | where-object {$_.displayname -like "*VLC*"}
if($null -eq $vlc){
write-host 'Installing VLC' -ForegroundColor yellow
Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/vlc-3.0.16-win64.exe' -Method 'GET' -OutFile "c:\support\software\vlc-3.0.16-win64.exe" 
start-process -WorkingDirectory "C:\Support\Software" -FilePath '.\vlc-3.0.16-win64.exe' -argumentlist '/L=1033 /S'
}

##################
# Zoom
##################
$zoom = $apps | where-object {$_.displayname -like "*zoom*"}
if($null -eq $zoom){
write-host 'Installing Zoom' -ForegroundColor yellow
invoke-webrequest -uri "https://boabcdn.blob.core.windows.net/cdn/ZoomInstaller.exe" -OutFile "C:\Support\Software\ZoomInstaller.exe"
start-process -workingdirectory 'C:\support\software' -filepath '.\ZoomInstaller.exe' 
start-sleep 10
$blockedProcesses = @('Zoom')
$runningProcesses = Get-Process | Where-Object { $blockedProcesses -contains $_.ProcessName }
if($runningProcesses -ne $null){
	Stop-Process -Name Zoom
}
}

##################
#Adobe Acrobat Pro
##################
$acrobat = $apps | where-object {$_.displayname -like "*Acrobat*"}
if($null -eq $acrobat){
#Disabled Enchanced Security
$FeatureLockDown = test-path -Path "HKLM:\SOFTWARE\Policies\Adobe\Adobe Acrobat\DC\FeatureLockDown" -ErrorAction SilentlyContinue
If($Testpath -eq $Null){
	New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Adobe\Adobe Acrobat\DC\FeatureLockDown" -Name "bEnhancedSecurityStandalone" -Value 0 
	New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Adobe\Adobe Acrobat\DC\FeatureLockDown" -Name "bEnhancedSecurityInBrowser" -Value 0 
} else {
	Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Adobe\Adobe Acrobat\DC\FeatureLockDown" -Name "bEnhancedSecurityStandalone" -Value 0 
	Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Adobe\Adobe Acrobat\DC\FeatureLockDown" -Name "bEnhancedSecurityInBrowser" -Value 0 
	}
}

##################
# CallSmart PBX
##################
$cpbx = $apps | where-object {$_.displayname -like "*cloudPBX*"}
if($null -eq $cbpx){
Write-host 'Installing CallSmart PBX..' -ForegroundColor yellow
invoke-webrequest -uri "https://aucdn.blob.core.windows.net/cloudpbx/CloudPBX_UC_current.msi" -OutFile 'C:\support\software\CloudPBX_UC_current.msi'
start-process -WorkingDirectory 'C:\support\software' -FilePath '.\CloudPBX_UC_current.msi' -ArgumentList '/quiet', '/norestart'  -wait
}

##################
# Install Cylance
##################
$cylance = $apps | where-object {$_.displayname -like "*Cylance*"}
if($null -eq $cylance){
Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/CylanceProtect_x64.zip' -Method 'GET' -OutFile "c:\support\software\CylanceProtect_x64.zip" 
unzip "c:\support\software\CylanceProtect_x64.zip" "c:\support\software\cylance"
msiexec /i c:\support\software\cylance\CylanceProtect_x64.msi /qn PIDKEY=RAqWoyAGgajdfqCh1gM1ncxHA LAUNCHAPP=1 PROTECTTEMPPATH=1
}

##################
# Install 7-zip
##################
Invoke-WebRequest -Uri "https://www.7-zip.org/a/7z2301-x64.exe" -OutFile 'C:\support\7z2301-x64.exe'
Start-Process -WorkingDirectory 'C:\support' -FilePath '.\7z2301-x64.exe' -ArgumentList '/S'

####################################################
# Install Pexa
####################################################
$pexa = $apps | where-object {$_.displayname -like "*Pexa*"}
if($null -eq $pexa){
Write-host 'Installing Pexa' -ForegroundColor yellow
Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/PexaDigitalSigning_1.0.12.105_x64.msi' -Method 'GET' -OutFile "c:\support\software\PexaDigitalSigning_1.0.12.105_x64.msi" 
start-process -WorkingDirectory 'c:\support\software' -FilePath '.\PexaDigitalSigning_1.0.12.105_x64.msi' -ArgumentList '/quiet' -wait
}

####################################################
# Install Pexa Certificate Software
####################################################
$PexaCert = $apps | where-object {$_.displayname -like "*Charismathics*"}
if($null -eq $PexaCert){
Write-host 'Installing Pexa' -ForegroundColor yellow
Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/CertificateSoftware.exe' -Method 'GET' -OutFile "c:\support\software\CertificateSoftware.exe" 
start-process -WorkingDirectory 'c:\support\software' -FilePath '.\CertificateSoftware.exe' -ArgumentList 'SP- /suppressmsgboxes /verysilent /norestart' -wait
}

####################################################
# Pexa Chrome Extension
####################################################
$chromeInstalled = (Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe').'(Default)').VersionInfo
if ($chromeInstalled.FileName -eq $null) {
    Write-Host "Chrome is not installed"
}else {
 
    <# .DESCRIPTION Adds a Google Chrome extension to the forced install list. Can be used for forcing installation of any Google Chrome extension. Takes existing extensions into account which might be added by other means, such as GPO and MDM. #>
    $extensionId = 'mehmbceeoajoljjbcodcbjlhmopjmlmf'
    Write-Information "ExtensionID = $extensionID"
    $extensionId = "$extensionId;https://clients2.google.com/service/update2/crx"
    $regKey = "HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist"
    if (!(Test-Path $regKey)) {
        New-Item $regKey -Force
        Write-Information "Created Reg Key $regKey"
    }
    # Add Extension to Chrome
    $extensionsList = New-Object System.Collections.ArrayList
    $number = 0
    $noMore = 0
    do {
        $number++
        Write-Information "Pass : $number"
        try {
            $install = Get-ItemProperty $regKey -name $number -ErrorAction Stop
            $extensionObj = [PSCustomObject]@{
                Name  = $number
                Value = $install.$number
            }
            $extensionsList.add($extensionObj) | Out-Null
            Write-Information "Extension List Item : $($extensionObj.name) / $($extensionObj.value)"
        }
        catch {
            $noMore = 1
        }
    }
    until($noMore -eq 1)
    $extensionCheck = $extensionsList | Where-Object { $_.Value -eq $extensionId }
    if ($extensionCheck) {
        $result = "Extension Already Exists"
        Write-Information "Extension Already Exists"
    }
    else {
        $newExtensionId = $extensionsList[-1].name + 1
        New-ItemProperty HKLM:\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist -PropertyType String -Name $newExtensionId -Value $extensionId
        $result = "Installed"

        Write-Host $result

    }
}

####################################################
# Install PingID
####################################################
$pingid = $apps | where-object {$_.displayname -like "*pingid*"}
if($null -eq $pingid){
Write-host 'Installing PingID' -ForegroundColor yellow
Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/PingID.exe' -Method 'GET' -OutFile "C:\Support\Software\PingID.exe" 
start-process -WorkingDirectory 'c:\support\software' -FilePath '.\PingID.exe' -ArgumentList '/verysilent' -wait
}

####################################################
# Cisco Webex
####################################################
$webex = $apps | where-object {$_.displayname -like "*webex*"}
if($null -eq $webex){
Write-host 'Installing Cisco Webex' -ForegroundColor yellow
Invoke-RestMethod 'https://binaries.webex.com/WebexTeamsDesktop-Windows-Gold/Webex.msi?_gl=1*tsd93u*_gcl_au*NzYyOTg5Mzk1LjE3MDEwNDk4NjM.' -Method 'GET' -OutFile "C:\Support\Software\Webex.msi" 
start-process -WorkingDirectory 'c:\support\software' -FilePath '.\Webex.msi' -ArgumentList '/quiet', '/norestart' -wait
}

####################################################
# Yealink USB Connect
####################################################
$YUC = $apps | where-object {$_.displayname -like "*Yealink*"}
if($null = $YUC){
Invoke-WebRequest "https://boabcdn.blob.core.windows.net/cdn/Yealink USB Connect-0.35.42.0.msi" -OutFile "C:\Support\software\Yealink USB Connect-0.35.42.0.msi"
write-host 'Installing Yealink Connect' -ForegroundColor yellow
Start-Process -WorkingDirectory "C:\Support\software" -filepath ".\Yealink USB Connect-0.35.42.0.msi" -Argumentlist "/quiet" -Wait
Write-host "Enterprise ID: difzbkke"
}

####################################################
# New Teams
####################################################
Invoke-WebRequest -uri "https://boabcdn.blob.core.windows.net/cdn/teamsbootstrapper.exe" -outfile "C:\Support\software\teamsbootstrapper.exe"
start-process -workingdirectory "C:\support\software" -filepath ".\teamsbootstrapper.exe" -ArgumentList "-p"


####################################################
# Drivers
####################################################
$csModel = get-computerinfo | select-object csmodel
#Surface Book 3
if ($csmodel.csmodel -eq "Surface Book 3") {
	$CheckDriver = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | where { $_.DisplayName -like "Surface book 3 update*" }
	If ($null -eq $CheckDriver) {
		$testpath = test-path C:\support\software\SurfaceBook3Drivers.msi
		If ($testpath -eq $false) {
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceBook3Drivers.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceBook3Drivers.msi"
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceBook3Drivers.msi' -ArgumentList '/quiet', '/norestart' -wait
		}
	}
}
#Surface Book 1
if ($csmodel.csmodel -eq "Surface Book") {
	$CheckDriver = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | where { $_.DisplayName -like "Surface book update*" }
	If ($null -eq $CheckDriver) {
		$testpath = test-path C:\support\software\SurfaceBook1Drivers.msi
		If ($testpath -eq $false) {
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceBook1Drivers.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceBook1Drivers.msi"
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceBook1Drivers.msi' -ArgumentList '/quiet', '/norestart' -wait  
		}
	}		
}      
#Surface Book 2
if ($csmodel.csmodel -eq "Surface Book 2") {
	$CheckDriver = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | where { $_.DisplayName -like "Surface book update*" }
	If ($null -eq $CheckDriver) {
		$testpath = test-path C:\support\software\SurfaceBook2Drivers.msi
		If ($testpath -eq $false) {
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceBook2Drivers.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceBook2Drivers.msi"
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceBook2Drivers.msi' -ArgumentList '/quiet', '/norestart' -wait
		}
	}		
}   
#Surface Laptop 4 Win 11
if($csmodel.csmodel -eq "Surface Laptop 4"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfaceLaptop4_Win11.msi
	if($os.WindowsProductName -like "Windows 11*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceLaptop4_Win11.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceLaptop4_Win11.msi"
		} 
		if($True -eq $testpath) {
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceLaptop4_Win11.msi' -ArgumentList '/quiet', '/norestart'
		}      
	}
}
#Surface Laptop 4 Win 10
if($csmodel.csmodel -eq "Surface Laptop 4"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfaceLaptop4_Win10.msi
	if($os.WindowsProductName -like "Windows 10*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceLaptop4_Win10.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceLaptop4_Win10.msi"
		} 
		if($True -eq $testpath) {
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceLaptop4_Win10.msi' -ArgumentList '/quiet', '/norestart'
		}      
	}
}
#Surface Laptop 5 Win 11
if($csmodel.csmodel -eq "Surface Laptop 5"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfaceLaptop5_Win11.msi
	if($os.WindowsProductName -like "Windows 11*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceLaptop5_Win11.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceLaptop5_Win11.msi"
		} 
		if($True -eq $testpath) {
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceLaptop5_Win11.msi' -ArgumentList '/quiet', '/norestart'
		}      
	}
}
#Surface Laptop 5 Win 10
if($csmodel.csmodel -eq "Surface Laptop 5"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfaceLaptop5_Win10.msi
	if($os.WindowsProductName -like "Windows 10*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceLaptop5_Win10.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceLaptop5_Win10.msi"
		} 
		start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceLaptop5_Win10.msi' -ArgumentList '/quiet', '/norestart' 
	}
}
#Surface Pro 9 Win 11
if($csmodel.csmodel -eq "Surface Laptop 5"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfacePro9_Win11.msi
	if($os.WindowsProductName -like "Windows 10*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfacePro9_Win11.msi' -Method 'GET' -OutFile "c:\support\software\SurfacePro9_Win11.msi"
		} 
		if($True -eq $testpath) {
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfacePro9_Win11.msi' -ArgumentList '/quiet', '/norestart'
		}      
	}
}
#Surface Pro 9 Win 10
if($csmodel.csmodel -eq "Surface Laptop 5"){
	$OS = Get-ComputerInfo
	$testpath = test-path C:\support\software\SurfacePro9_Win10.msi
	if($os.WindowsProductName -like "Windows 11*"){
		If($testpath -eq $false){
			Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfacePro9_Win10.msi' -Method 'GET' -OutFile "c:\support\software\SurfacePro9_Win10.msi"
		} 
		if($True -eq $testpath) {
			start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfacePro9_Win10.msi' -ArgumentList '/quiet', '/norestart'
		}      
	}
}
#NUC10i5FNH
if ($csmodel.csmodel -eq "NUC10i5FNH") {
	$testpath = Test-Path -path C:\support\software\NUC10i5FNHDriver.zip
	if ($testpath -eq $false) {
		Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/NUC10i5FNHDriver.zip' -Method 'GET' -OutFile "c:\support\software\NUC10i5FNHDrivers.zip" 
		unzip "c:\support\software\NUC10i5FNHDrivers.zip" "c:\support\software"   
		#WiFi/LAN
		start-process -WorkingDirectory 'C:\support\software\NUC10i5FNH\BT_22.30.0_64_Win10' -FilePath '.\WirelessSetup.exe' -ArgumentList '/qn' -wait
		#ME Firmware
		start-process -WorkingDirectory 'C:\support\Software\NUC10i5FNH\me_win10_1931.14.0.1323\ME_Win10_1931.14.0.1323' -FilePath '.\MEISetup.exe' -ArgumentList '-s' -wait
		#Serial IO
		start-process -WorkingDirectory 'C:\support\Software\NUC10i5FNH\serialio_win10_30.100.1947.3' -FilePath '.\SetupSerialIO.exe' -ArgumentList '-s' -wait
		#Thunderbolt
		start-process -WorkingDirectory 'C:\support\Software\NUC10i5FNH\tbt-win10-1.41.1054.0' -FilePath '.\Thunderbolt(TM) Software Installer.exe' -ArgumentList '/install /quiet /norestart' -wait
		#RST
		start-process -WorkingDirectory 'C:\support\Software\NUC10i5FNH\rst-win10-18.0.1.1138.1' -FilePath '.\SetupRST.exe' -ArgumentList '-accepteula -silent' -wait
		#Bluetooth / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\software\NUC10i5FNH\BT_22.30.0_64_Win10' -FilePath '.\Intel Bluetooth.msi' -ArgumentList '/qn' -wait
		#LAN / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\software\NUC10i5FNH\PROWinx64_26_0\PROWinx64\APPS\PROSETDX\Winx64' -FilePath '.\DxSetup.exe' -ArgumentList '/qn /norestart' -wait
		#Audio / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\Software\NUC10i5FNH\aud_win10_64_6.0.8950.1\Audio_Win10_20H1_Realtek_8950.1' -FilePath '.\setup.exe' -ArgumentList '/s' -wait
		#HDMI Firmware
		start-process -WorkingDirectory 'C:\support\software\NUC10i5FNH\NUC10ixFN-HDMI_Firmware_Update_Tool-1.78.2.0.7' -FilePath '.\BobcatAuxISPTool.exe' -wait
	}  
}
#NUC7i5BNH
if ($csmodel.csmodel -eq "NUC7i5BNH") {
	$testpath = Test-Path -path C:\support\software\NUC7i5BNHDrivers.zip
	if ($testpath -eq $false) {
		Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/NUC7i5BNHDriver.zip' -Method 'GET' -OutFile "c:\support\software\NUC7i5BNHDrivers.zip" 
		unzip "c:\support\software\NUC7i5BNHDrivers.zip" "c:\support\software"
		#WiFi/LAN
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH' -filepath '.\wifi_win10_64_21.120.2.exe' -ArgumentList '/s' -wait
		#ME Firmware
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH\me-consumer-win10-19h1-20h1-12.0.70.1648' -FilePath '.\SetupME.exe' -ArgumentList '-s' -wait
		#Chipset
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH\chipset_win7_8.1_10_10.1.1.38' -FilePath '.\SetupChipset.exe' -ArgumentList '-s -norestart' -wait
		#Thunderbolt
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH\thunderbolt-win10-1.41.1094.0' -FilePath '.\Thunderbolt(TM) Software Installer.exe' -ArgumentList '/install /quiet /norestart' -wait
		#Graphics
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH\gfx_win10_64_24.20.100.6286_bn' -FilePath '.\igxpin.exe' -ArgumentList '-s'  -wait
		#Bluetooth / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\software\NUC7i5BNH\BT_22.30.0_64_Win10' -FilePath '.\Intel Bluetooth.msi' -ArgumentList '/qn' -wait
		#LAN / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\software\NUC7i5BNH\PROWinx64_26_0\PROWinx64\APPS\PROSETDX\Winx64' -FilePath '.\DxSetup.exe' -ArgumentList '/qn /norestart' -wait
		#Audio / Base drivers - same directory
		start-process -WorkingDirectory 'C:\support\Software\NUC7i5BNH\aud_win7_8.1_10_64_6.0.1.8192' -FilePath '.\setup.exe' -ArgumentList '/s' -wait
	}
}
if ($csmodel.csmodel -eq "NUC11PAHi7") {
	$testpath = Test-Path -path C:\support\software\NUC11PAHi7.zip
	if ($testpath -eq $false) {
		Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/NUC11PAHi7.zip' -Method 'GET' -OutFile "c:\support\software\NUC11PAHi7.zip" 
		unzip "c:\support\software\NUC11PAHi7.zip" "c:\support\software"
		#CardReader
		Write-host 'Installing Card Reader Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\CardReader' -filepath '.\ITECIR.exe' -ArgumentList '/s' -wait
		#Chipset
		Write-host 'Installing Chipset Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\Chipset' -filepath '.\SetupChipset.exe' -ArgumentList '-s -norestart' -wait
		#Graphics
		Write-host 'Installing Graphics Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\Graphics' -filepath '.\igxpin.exe' -ArgumentList '-s' -wait
		#ManagementEngine
		Write-host 'Installing ManagementEngine Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\ManagementEngine' -filepath '.\SetupME.exe' -ArgumentList '-s' -wait
		#Intel NUC Software Stuido Service
		Write-host 'Installing Intel NUC Software Stuido Service Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\Intel NUC Software Studio Service' -filepath '.\NSSServiceInstaller.msi' -ArgumentList '/quiet /norestart' -wait
		#RST
		#Write-host 'Installing RST Driver..' -ForegroundColor Yellow
		#start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\RST' -filepath '.\SetupRST.exe' -ArgumentList '-s -accepteula' -wait
		#SDCard
		Write-host 'Installing SDCard Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\SDCard' -filepath '.\Setup.exe' -ArgumentList '/quiet /norestart' -wait
		#SerialIO
		Write-host 'Installing SerialIO Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\Serial IO' -filepath '.\SetupSerialIO.exe' -ArgumentList '-s' -wait
		#Bluetooth
		#Write-host 'Installing Bluetooth Driver..' -ForegroundColor Yellow
		#start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\Bluetooth' -filepath '.\bt_22.40.0_64_win10.exe' -ArgumentList '-s' -wait
		#WiFi
		Write-host 'Installing WiFi Driver..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\WIFI' -filepath '.\wifi_22.40.0_driver64_win10.exe' -ArgumentList '-s' -wait
		#BIOS
		Write-host 'Installing BIOS Update..' -ForegroundColor Yellow
		start-process -WorkingDirectory 'D:\Software\NUC11PAHi7\BIOS' -filepath '.\PATGL357.0041.EBU.exe' -wait
	}
}
if ($csmodel.csmodel -eq "NUC12WSKI7") {
    $testpath = Test-Path -path C:\support\software\NUC12WSKI7.zip
    if ($testpath -eq $false) {
        Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/NUC12WSKi7.zip' -Method 'GET' -OutFile "c:\support\software\NUC12WSKi7.zip" 
        unzip "c:\support\software\NUC12WSKi7.zip" "c:\support\software"   
        #Patch for a Modern Standby LAN Issue
        reg.exe C:\support\software\NUC12WSKi7\AUTO_GEN_PEP_DISABLE.reg
        #WIFI
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\WiFi' -filepath '.\WirelessSetup.exe' -ArgumentList '-s' -wait
        #Bluetooth          
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\Bluetooth\' -filepath '.\Intel Bluetooth.msi' -ArgumentList '/quiet', '/norestart'
        #Chipset
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\Chipset\' -filepath '.\SetupChipset.exe' -ArgumentList '/quiet', '/norestart' -wait
        #ME Firmware
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\ME Chipset\' -filepath '.\SetupME.exe' -ArgumentList '-s' -wait
        #SerialIO
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\SerialIO\' -filepath '.\SetupSerialIO.exe' -ArgumentList '-s' -wait
        #Thunderbolt
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\Thunderbolt\' -filepath '.\Thunderbolt(TM) Software Installer.exe' -ArgumentList '/quiet', '/norestart' -wait
        #Audio
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7\Audio\AUD-Win10_Win11-6.0.9437.1_iSST_10.29.00.7767' -FilePath '.\setup.exe' -ArgumentList '-s' -wait
        #BIOS
        start-process -WorkingDirectory 'C:\support\software\NUC12WSKi7' -FilePath '.\WSADL357.0087.EBU.exe' -wait

    }
}
#Surface Pro 7
if ($csmodel.csmodel -eq "Surface Pro 7") {
	$testpath = test-path C:\support\software\SurfacePro7Drivers.msi
	If ($testpath -eq $false) {
		Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfacePro7Drivers.msi' -Method 'GET' -OutFile "c:\support\software\SurfacePro7Drivers.msi"
		start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfacePro7Drivers.msi' -ArgumentList '/quiet', '/norestart' -wait
	}
}
#Surface Dock 1 Firmware
if ($csmodel.csmodel -like "*Surface*") {
	Invoke-RestMethod 'https://boabcdn.blob.core.windows.net/cdn/SurfaceDock1Firmware.msi' -Method 'GET' -OutFile "c:\support\software\SurfaceDock1Firmware.msi"
	start-process -WorkingDirectory 'C:\support\software' -FilePath '.\SurfaceDock1Firmware.msi' -ArgumentList '/quiet', '/norestart' -wait
}

####################################################
# Install LEAP
####################################################
Add-Type -AssemblyName PresentationFramework
$msgBoxInput = [System.Windows.MessageBox]::Show("Install LEAP?.", 'Install LEAP', 'YesNo', 'Information')
switch ($msgBoxInput) {
	'Yes' {
	Invoke-WebRequest -Uri 'https://www.dropbox.com/scl/fi/w7qdxme2df2s1ad9myk5t/LEAPDesktopX64Setup.exe?rlkey=11sins6zi694kgp9kapzb5ztq&dl=1' -OutFile 'C:\support\LEAPDesktopX64Setup.exe'
	start-process -WorkingDirectory 'C:\support\software' -FilePath '.\LEAPDesktopX64Setup.exe' -ArgumentList '/S', '/v/qn' -Wait
	
    New-NetFirewallRule -DisplayName "LEAP Desktop" -Direction Inbound -Program "C:\Program Files\LEAP Office\Cloud\LEAP Desktop.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP Timesheet" -Direction Inbound -Program "C:\Program Files\LEAP Office\Timesheet\Leap.Timesheet.Shell.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP Office XE" -Direction Inbound -Program "C:\ProgramData\LEAP Office\Cloud\Net Client\LeapOfficeXE.NetClient.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP PDF" -Direction Inbound -Program "C:\ProgramData\LEAP Office\Cloud\Extras\LeaPDF\LeaPDF.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP Print" -Direction Inbound -Program "C:\ProgramData\LEAP Office\Cloud\Extras\LEAPPrint\LEAPPrint.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP Calc" -Direction Inbound -Program "C:\ProgramData\LEAP Office\Cloud\LEAPCalc\leap-calc.exe" -Action Allow
    New-NetFirewallRule -DisplayName "LEAP Audit" -Direction Inbound -Program "C:\Users\%Username%\AppData\Local\Programs\leap-audit-tool.exe" -Action Allow


}
'No' {
	Write-Host 'Cancelled' -foregroundcolor yellow
    $msgBoxInput = [System.Windows.MessageBox]::Show("Tnstallation complete.")
}
}

$msgBoxInput = [System.Windows.MessageBox]::Show("Tnstallation complete.")