This commit is contained in:
Kenneth Benzie 2024-08-09 12:54:43 +01:00
parent 2e60d0c414
commit 8e791a4826

View File

@ -36,52 +36,53 @@ if (-Not $is_elevated) {
} }
# Running with elevated permissions # Running with elevated permissions
Write-Host "Press Enter to exit..."
[System.Console]::ReadLine() | Out-Null
# # Install 1Password
# $decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $choices, 0)
# if ($decision -eq 0) {
# $1password_installer = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe"
# Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1password_installer"
# &$1password_installer
# Remove-Item $1password_installer
# } else {
# echo 'Skipping 1Password'
# }
# Install 1Password # # Enable Hyper-V
$decision = $Host.UI.PromptForChoice('Install 1Password', 'Proceed?', $choices, 0) # $decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $choices, 0)
if ($decision -eq 0) { # if ($decision -eq 0) {
$1password_installer = "$env:USERPROFILE/Downloads/1PasswordSetup-latest.exe" # Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Invoke-WebRequest -Uri "https://downloads.1password.com/win/1PasswordSetup-latest.exe" -OutFile "$1password_installer" # } else {
&$1password_installer # echo 'Skipping Hyper-V'
Remove-Item $1password_installer # }
} else {
echo 'Skipping 1Password'
}
# Enable Hyper-V # # Enable Containters
$decision = $Host.UI.PromptForChoice('Enable Hyper-V', 'Proceed?', $choices, 0) # $decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $choices, 0)
if ($decision -eq 0) { # if ($decision -eq 0) {
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All # Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
} else { # } else {
echo 'Skipping Hyper-V' # echo 'Skipping Containers'
} # }
# Enable Containters # # Get the shell application object
$decision = $Host.UI.PromptForChoice('Enable Containers', 'Proceed?', $choices, 0) # $shellApp = New-Object -ComObject "Shell.Application"
if ($decision -eq 0) {
Enable-WindowsOptionalFeature -Online -FeatureName Containers -All
} else {
echo 'Skipping Containers'
}
# Get the shell application object # # Run the command without elevation
$shellApp = New-Object -ComObject "Shell.Application" # $shellApp.ShellExecute("powershell.exe", "-NoProfile -Command `"& { $nonElevatedCommand }`"", "", "open", 0)
# Run the command without elevation # # Start-Process -NoNewWindow -Credential "$env:UserDomain\$env:UserName" -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }"
$shellApp.ShellExecute("powershell.exe", "-NoProfile -Command `"& { $nonElevatedCommand }`"", "", "open", 0) # # Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }" -Credential $user -WindowStyle Hidden
# Start-Process -NoNewWindow -Credential "$env:UserDomain\$env:UserName" -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }" # # Install Chocolatey
# Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -Command & { & $($command) }" -Credential $user -WindowStyle Hidden # iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# Install Chocolatey # # Install SSH Server
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) # $decision = $Host.UI.PromptForChoice('Install SSH Server', 'Proceed?', $choices, 0)
# if ($decision -eq 0) {
# Install SSH Server # choco install --yes "--package-parameters=/SSHServerFeature" openssh
$decision = $Host.UI.PromptForChoice('Install SSH Server', 'Proceed?', $choices, 0) # Start-Service sshd
if ($decision -eq 0) { # Set-Service -Name sshd -StartupType 'Automatic'
choco install --yes "--package-parameters=/SSHServerFeature" openssh # } else {
Start-Service sshd # echo 'Skipping SSH Server'
Set-Service -Name sshd -StartupType 'Automatic' # }
} else {
echo 'Skipping SSH Server'
}