2023-03-07 12:28:00 -08:00
|
|
|
<#
|
|
|
|
|
.NOTES
|
|
|
|
|
Author : Chris Titus @christitustech
|
|
|
|
|
Runspace Author: @DeveloperDurp
|
|
|
|
|
GitHub : https://github.com/ChrisTitusTech
|
|
|
|
|
Version : #{replaceme}
|
|
|
|
|
#>
|
2024-01-15 11:32:19 -06:00
|
|
|
param (
|
|
|
|
|
[switch]$Debug,
|
|
|
|
|
[string]$Config,
|
|
|
|
|
[switch]$Run
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Set DebugPreference based on the -Debug switch
|
|
|
|
|
if ($Debug) {
|
|
|
|
|
$DebugPreference = "Continue"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($Config) {
|
|
|
|
|
$PARAM_CONFIG = $Config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$PARAM_RUN = $false
|
|
|
|
|
# Handle the -Run switch
|
|
|
|
|
if ($Run) {
|
|
|
|
|
Write-Host "Running config file tasks..."
|
|
|
|
|
$PARAM_RUN = $true
|
|
|
|
|
}
|
2023-03-07 12:28:00 -08:00
|
|
|
|
2024-01-12 00:34:41 -06:00
|
|
|
if (!(Test-Path -Path $ENV:TEMP)) {
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $ENV:TEMP
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 12:28:00 -08:00
|
|
|
Start-Transcript $ENV:TEMP\Winutil.log -Append
|
|
|
|
|
|
2023-10-19 17:12:55 -05:00
|
|
|
# Load DLLs
|
2023-11-28 16:11:11 -06:00
|
|
|
Add-Type -AssemblyName PresentationFramework
|
2023-03-07 12:28:00 -08:00
|
|
|
Add-Type -AssemblyName System.Windows.Forms
|
|
|
|
|
|
2023-10-19 17:12:55 -05:00
|
|
|
# Variable to sync between runspaces
|
2023-03-07 12:28:00 -08:00
|
|
|
$sync = [Hashtable]::Synchronized(@{})
|
|
|
|
|
$sync.PSScriptRoot = $PSScriptRoot
|
|
|
|
|
$sync.version = "#{replaceme}"
|
|
|
|
|
$sync.configs = @{}
|
|
|
|
|
$sync.ProcessRunning = $false
|
2023-07-13 15:46:00 -05:00
|
|
|
|
2024-06-04 20:27:27 -07:00
|
|
|
# If script isn't running as admin, show error message and quit
|
2024-08-06 23:35:17 +03:00
|
|
|
If (([Security.Principal.WindowsIdentity]::GetCurrent()).Owner.Value -ne "S-1-5-32-544") {
|
2024-03-30 11:46:29 -05:00
|
|
|
Write-Host "===========================================" -Foregroundcolor Red
|
|
|
|
|
Write-Host "-- Scripts must be run as Administrator ---" -Foregroundcolor Red
|
|
|
|
|
Write-Host "-- Right-Click Start -> Terminal(Admin) ---" -Foregroundcolor Red
|
|
|
|
|
Write-Host "===========================================" -Foregroundcolor Red
|
2023-11-28 16:11:11 -06:00
|
|
|
break
|
2024-06-04 20:27:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Set PowerShell window title
|
|
|
|
|
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Admin)"
|
|
|
|
|
clear-host
|