Skip to content

Commit

Permalink
First test run fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmens committed Jun 9, 2024
1 parent e45599c commit 09af6c0
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
30 changes: 22 additions & 8 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ else {
exit
}

#===============================================================
# Install Chocolatey
#===============================================================

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

#===============================================================
# Execute all scripts in the scripts directory
#===============================================================
Expand All @@ -81,13 +87,21 @@ if (Test-Path $scriptsDir) {
Write-Output "Executing script: $($scriptFile.FullName)"

try {
# Execute the script
& $scriptFile.FullName `
-systemPurpose $systemPurpose `
-systemOwnership $systemOwnership `
-userPassword $userPassword `
-computerName $computerName `
-workgroupName $workgroupName
# Construct the argument list
$arguments = @(
"-File `"$($scriptFile.FullName)`"",
"-systemPurpose `"$systemPurpose`"",
"-systemOwnership `"$systemOwnership`"",
"-userPassword `"$userPassword`"",
"-computerName `"$computerName`"",
"-workgroupName `"$workgroupName`""
)

# Join the arguments into a single string
$argumentString = $arguments -join ' '

# Execute the script as an administrator in a new process and window
Start-Process -FilePath "powershell.exe" -ArgumentList $argumentString -Verb RunAs -WindowStyle Normal

Write-Output "Successfully executed script: $($scriptFile.FullName)"
}
Expand All @@ -96,7 +110,7 @@ if (Test-Path $scriptsDir) {
}
}

Write-Output "All scripts executed."
Write-Output "All scripts spawned."
}
else {
Write-Error "Script directory does not exist: $scriptsDir"
Expand Down
3 changes: 3 additions & 0 deletions scripts/apps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ if (-not $appScripts.ContainsKey($systemPurpose)) {
Write-Output "Installing apps for '$systemPurpose' with '$systemOwnership' ownership..."
Install-Apps -purpose $systemPurpose -ownership $systemOwnership
Write-Output "Installation complete."

# Prevent the script from closing immediately
Read-Host -Prompt "Press Enter to exit..."
1 change: 0 additions & 1 deletion scripts/choco.ps1

This file was deleted.

5 changes: 5 additions & 0 deletions scripts/power.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Write-Output "Setting power schemes"

# Set monitor timeout for AC and DC power
powercfg.exe /change monitor-timeout-ac 30
powercfg.exe /change monitor-timeout-dc 30
Expand All @@ -16,3 +18,6 @@ powercfg.exe /change hibernate-timeout-dc 0

# Turn off hibernation
powercfg.exe /hibernate off

# Prevent the script from closing immediately
Read-Host -Prompt "Press Enter to exit..."
3 changes: 3 additions & 0 deletions scripts/users.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ if ($userName -ne "") {

# Set maximum password age to unlimited
Start-Process -FilePath "cmd.exe" -ArgumentList "/c net accounts /maxpwage:unlimited" -NoNewWindow -Wait -Verb RunAs

# Prevent the script from closing immediately
Read-Host -Prompt "Press Enter to exit..."
12 changes: 11 additions & 1 deletion scripts/workgroupname.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ $currentWorkgroup = (Get-CimInstance -ClassName Win32_ComputerSystem).Domain
if ($currentComputerName -ne $computerName) {
Write-Output "Changing computer name from $currentComputerName to $computerName..."
Rename-Computer -NewName $computerName -Force
Write-Output "WARNING: The changes will take effect after you restart the computer $currentComputerName."
}
else {
Write-Output "Computer name is already $computerName. No change needed."
}

# Check and update the workgroup if necessary
if ($currentWorkgroup -ne $workgroup) {
if ($currentWorkgroup -ne $workgroupName) {
Write-Output "Changing workgroup from $currentWorkgroup to $workgroupName..."
Add-Computer -WorkGroupName $workgroupName
}
else {
Write-Output "Workgroup is already $workgroupName. No change needed."
}

# Prevent the script from closing immediately
Read-Host -Prompt "Press Enter to exit..."

0 comments on commit 09af6c0

Please sign in to comment.